[solved] initial values for transform

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
User avatar
Kia
Eileen-Class Veteran
Posts: 1011
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

[solved] initial values for transform

#1 Post by Kia » Fri Oct 22, 2021 4:57 am

I have this:

Code: Select all

default objects = []
init python:
    def add_one():
        objects.append([renpy.random.randint(10, 1910), renpy.random.randint(10, 1070)])

    def move_left():
        for i in objects:
            i[0] -= 100

screen initial_test():
    hbox:
        spacing 10
        button:
            background "#444"
            text "add one"
            action Function(add_one)
        button:
            background "#444"
            text "move left"
            action Function(move_left)
    for i in objects:
        frame:
            xysize 20,20
            at object_pos(i[0], i[1])

transform object_pos(x, y):
    linear .4 xpos x ypos y


label start:
    call screen initial_test
    return
And I can't figure out any way to remove that initial animation when the objects are added, I wonder is there's any way to give the transform an initial set of values to omit moving from 0,0 to the given x,y?
I've tried (on show, on update, block, contains) and anything with a chance to effect the outcome, to no avail.
Last edited by Kia on Fri Oct 22, 2021 10:37 am, edited 1 time in total.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: initial values for transform

#2 Post by Ocelot » Fri Oct 22, 2021 6:16 am

What I came to:

Code: Select all

default objects = []

init python:
    class Point:
        def __init__(self, x, y):
            self.x = x
            self.y = y
            self.initial_position = True

    def add_one():
        objects.append(Point(renpy.random.randint(10, 1270), renpy.random.randint(10, 710)))

    def move_left():
        for i in objects:
            i.x -= 100
            i.initial_position = False

screen initial_test():
    hbox:
        spacing 10
        button:
            background "#444"
            text "add one"
            action Function(add_one)
        button:
            background "#444"
            text "move left"
            action Function(move_left)
    for i in objects:
        frame:
            if i.initial_position:
                at object_pos(i.x, i.y, 0.0)
            else:
                at object_pos(i.x, i.y, 0.4)
            xysize 20,20

transform object_pos(x, y, dur):
        linear dur xpos x ypos y

label start:
    call screen initial_test
    return
(Replacing list with a class is not strictly nessesary, I just prefer names to indexes)
< < insert Rick Cook quote here > >

User avatar
Kia
Eileen-Class Veteran
Posts: 1011
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: [solved] initial values for transform

#3 Post by Kia » Fri Oct 22, 2021 10:39 am

thank you ^^
I was so focused on modifying the transform, missed the solution that should've been obvious to me :oops:

Post Reply

Who is online

Users browsing this forum: Bing [Bot], span4ev