ATL Block code Strip help. mainly Framerate

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
nhguy03276
Regular
Posts: 41
Joined: Thu Jan 29, 2015 12:48 pm
Contact:

ATL Block code Strip help. mainly Framerate

#1 Post by nhguy03276 »

So, here again, I seem to be stumped.


I came across a chunk of code that allowed me to turn this:http://i.imgur.com/Sb2gKYi.png
into a dancing character, yet I really don't know what I'm doing.

Code: Select all

   

 def PortraitStrip(st, at, image, width, frames):
        f = min([frames, math.trunc(st * 10)])
       
        frame = im.Crop("characters/%s" % image, (f * width, 0, width, 640))
        return frame, .1


        

init:
  image anubis dance:
        DynamicDisplayable(PortraitStrip, "anubis/dance1.png", 480, 11)
        pause 1.3
        repeat



start:

show anubis dance
This works great for the most part. However, I wish to be able to change the framerate. The dancing anubis displays at about 12 fps which is good, however, I'd like to slow the disco floor (not Shown) down to about 1 fps. I've tried everything I can think of, but any pause I've tried to insert into this code only pauses the display and not the position of the frame, resulting in skips. A test version of the strip was numbered, and when I tried slowing things down, I'd get things like Frame1, Frame 5, frame 9. but not the others. So how can I make the rate the images are displayed variable?

The next question, I also would like for the dancing anubis to say random things, in random order, such as "weee", "Look at me, I'm Dancing", " Around around I go", "I'm starting to get dizzy". Sort of background stuff, that doesn't affect the story. So again, the filmstrip, add all the lines to the different frames, and have it pick a random frame. I think I know how to do this, but while I'm asking questions, I figured I'd ask this as well.

Any help?
Thanks in advance.

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: ATL Block code Strip help. mainly Framerate

#2 Post by philat »

Any reason you're not using Filmstrip, which has a built-in delay parameter? http://www.renpy.org/wiki/renpy/doc/ref ... .Filmstrip

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: ATL Block code Strip help. mainly Framerate

#3 Post by Donmai »

philat wrote:Any reason you're not using Filmstrip, which has a built-in delay parameter? http://www.renpy.org/wiki/renpy/doc/ref ... .Filmstrip
I believe he's trying to use this Cookbook recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=30279
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

nhguy03276
Regular
Posts: 41
Joined: Thu Jan 29, 2015 12:48 pm
Contact:

Re: ATL Block code Strip help. mainly Framerate

#4 Post by nhguy03276 »

Donmai wrote:I believe he's trying to use this Cookbook recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=30279
Yes that is where I got the base code from.
philat wrote:Any reason you're not using Filmstrip, which has a built-in delay parameter? http://www.renpy.org/wiki/renpy/doc/ref ... .Filmstrip
Why am I not using Filmstrip. Well, for a couple reasons.

1. I found the code I'm using before finding the filmstrip code.

2. The "strip" code is part of the portrait code, and there are some other parts of that code that are of use to me. I only posted the relevant "strip code" for this post however.

3. Somewhere along the line, Someone gave me the impression that Filmstrip doesn't take secondary ATL codes, and by using this kind of code, you can use secondary ATL code. Now I took this to mean resizing, fading, flipping and other transitions. I don't know if this is true, False, a misunderstanding or just outdated information.

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: ATL Block code Strip help. mainly Framerate

#5 Post by philat »

Well, I'm honestly crap at any of the actual rendering engine stuff, but I poked around the code in the cookbook and this seems to work.

Code: Select all

    def PortraitStrip(st, at, image, width, frames, speed=1):
        f = min([frames, math.trunc(st * speed * 10)])
        frame = im.Crop("graphics/char/%s" % image, (f * width, 0, width, 640))
        return frame, 0.1

  image anubis dance_fast:
        DynamicDisplayable(PortraitStrip, "anubis/dance1.png", 480, 11)
        pause 1.3
        repeat

  image anubis dance_slow:
        DynamicDisplayable(PortraitStrip, "anubis/dance1.png", 480, 11, 0.5) #half speed
        pause 2.6 # since it's half speed
        repeat
ETA: On the saying random things front, I don't think just adding stuff to the frames themselves works, since the animation by necessity has to show in a certain order. You can use choice and contains in ATL to layer a random image on top of the dancing anubis, I guess.

nhguy03276
Regular
Posts: 41
Joined: Thu Jan 29, 2015 12:48 pm
Contact:

Re: ATL Block code Strip help. mainly Framerate

#6 Post by nhguy03276 »

philat wrote:Well, I'm honestly crap at any of the actual rendering engine stuff, but I poked around the code in the cookbook and this seems to work.

Code: Select all

    def PortraitStrip(st, at, image, width, frames, speed=1):
        f = min([frames, math.trunc(st * speed * 10)])
        frame = im.Crop("graphics/char/%s" % image, (f * width, 0, width, 640))
        return frame, 0.1

  image anubis dance_fast:
        DynamicDisplayable(PortraitStrip, "anubis/dance1.png", 480, 11)
        pause 1.3
        repeat

  image anubis dance_slow:
        DynamicDisplayable(PortraitStrip, "anubis/dance1.png", 480, 11, 0.5) #half speed
        pause 2.6 # since it's half speed
        repeat
ETA: On the saying random things front, I don't think just adding stuff to the frames themselves works, since the animation by necessity has to show in a certain order. You can use choice and contains in ATL to layer a random image on top of the dancing anubis, I guess.
Thank you, that worked perfectly. I knew it couldn't be that hard to change the speeds it displayed, I just had no idea it would be that simple.


As for the random thing, I have some ideas, but If I can't pick a random frame, Say 5 then 2, then 8, I guess I don't have to use the filmstrip thing, but single images to get what I want. I'm just trying to keep the graphics heavy plan somewhat under control.

nhguy03276
Regular
Posts: 41
Joined: Thu Jan 29, 2015 12:48 pm
Contact:

Re: ATL Block code Strip help. mainly Framerate

#7 Post by nhguy03276 »

In case anyone needs it for the future, here is a bit of code for some random image display. It's a bit rough, and I'm still not sure of the math that makes the pause/frate/display display properly, but it works.

Code: Select all

  

init python:
    
    import random
    import math


  def PortraitStrip(st, at, image, width, frames, speed):
        f = min([frames, math.trunc(st * speed * 10)])
        frame = im.Crop( image, (f * width, 0, width, 640))
        return frame, .1

   
    def randomsay (st, at, image, width, frames, speed, frate):
        randomframe = renpy.random.randint(0, frames )
        f = min([randomframe, math.trunc (st * speed * 10)]) 
        frame = im.Crop(  image, (randomframe * width, 0, width, 640))

        return frame, frate

init:
  image anubis_dance:
        DynamicDisplayable(PortraitStrip, "characters/anubis/dance1.png", 480, 11, 1)
        pause 1.3
        repeat
        
  image anubis_say:
        DynamicDisplayable(randomsay, "says/saytest.png", 480, 9, .001, 5 )
        pause 1300
        repeat
    
  image discofloor_an:
        DynamicDisplayable(randomsay, "props/discofloor.png", 960, 2, 1, 1 )
        pause .3
        repeat


To Randomly say things create an image file with the phrases in each frame. since I don't want the character yapping constantly, I left several blank spots, in which no text was displayed.
http://i.imgur.com/DBPwkvm.png (might not be able to see it...)

Of Note: it appears that the first frame in a strip is frame 0, so when putting the number of frames in your define line, make sure to minus 1, (If you have 10 frames put 9 in the frames column, 3 you'd use 2, etc) if not you'll get a out of bounds error. All frames are displayed however.

Post Reply

Who is online

Users browsing this forum: Google [Bot], henne