ATL Function Statement

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
UngarHansel
Newbie
Posts: 1
Joined: Fri Nov 17, 2023 10:30 pm
Contact:

ATL Function Statement

#1 Post by UngarHansel »

Hello! Help me please. I need to make an animation using Function Statement https://www.renpy.org/doc/html/atl.html ... -statement.
I need a function to use renpy.random.randint for the coordinates and speed "lenear". So that each cycle has different coordinates (if this is possible).
But I can’t do it, I don’t understand how exactly it works, I’m new to Python.
I need animation like in this example, Movement in one direction and then back without breaking the image. Thank you for your attention!

Code: Select all

 show ball1:
        
        linear 1.0 xpos 320 ypos 10 rotate 45 zoom 1
        
        pause 3
  
          
        linear 0.7 xpos 650 ypos 800 rotate 300 zoom 2.5

        pause 3
        
        repeat
          
        

Thanks to Google translator.

User avatar
m_from_space
Eileen-Class Veteran
Posts: 1162
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: ATL Function Statement

#2 Post by m_from_space »

UngarHansel wrote: Fri Nov 17, 2023 11:04 pm But I can’t do it, I don’t understand how exactly it works, I’m new to Python.
In my experience it's not really possible to do randomization using an ATL function. But you can use screens for that matter. Here is an example, you can figure out the zoom property yourself I guess. :)

Code: Select all

transform move_rotate(x0, y0, r0, x1, y1, r1, t):
    anchor (0.5, 0.5)
    subpixel True
    xpos x0 ypos y0 rotate r0
    linear t xpos x1 ypos y1 rotate r1

default anim_x0 = 0
default anim_y0 = 0
default anim_r0 = 0
default anim_x1 = 0
default anim_y1 = 0
default anim_r1 = 0
default anim_t = 1.0

init python:
    def anim_randomize():
        store.anim_x0 = store.anim_x1
        store.anim_y0 = store.anim_y1
        store.anim_r0 = store.anim_r1
        store.anim_x1 = renpy.random.randint(100, 1180)
        store.anim_y1 = renpy.random.randint(100, 620)
        store.anim_r1 = renpy.random.randint(0, 360)
        # a random animation time between 2.0 and 4.0 seconds
        store.anim_t = 2 * renpy.random.random() + 2.0
        return

screen anim_screen(anim_img, anim_pause=3.0):
    add anim_img at move_rotate(anim_x0, anim_y0, anim_r0, anim_x1, anim_y1, anim_r1, anim_t)
    timer anim_t + anim_pause action Function(anim_randomize) repeat True

label start:
    show screen anim_screen("ball1")
    "Fin."

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Wimble