Trying to figure out how to animate a thing...[Solved]

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
Mutive
Veteran
Posts: 344
Joined: Tue Nov 21, 2017 2:23 am
Completed: Eidolon, Minion!, Love Furever, Epilogue
Contact:

Trying to figure out how to animate a thing...[Solved]

#1 Post by Mutive »

I'm feeling like an idiot, as this seems like it should be an easy thing to do...

My goal is to have a player click on a map, at which point there's an animation of the sprite moving from the starting location to the clicked on location.

I'd like to be able to set the coordinates for the sprite as simply as possible (e.g. the sprite moves from point (100, 100) to point (300, 300) on the map at a rate of, say, 100 pixels per 0.3 seconds. Or whatever.

I've tried to do this via creating an animation that I can lay over a background something like this:

Code: Select all

image hero_map1:
    'images/hero.jpg' pos (100, 100)
    pause 0.3
    'images/hero.jpg' pos (200, 200)
    pause 0.3
    'images/hero.jpg' pos (300, 300)
Renpy does *not* like this, although it's pretty willing to accept:

Code: Select all

image hero_map1:
    'images/hero.jpg'
    pause 0.3
    'images/hero.jpg'
    pause 0.3
    'images/hero.jpg'
Just, like, if I do that, my character doesn't move. The character just hovers at the bottom of the screen where it is of no use to anyone.

I feel like I'm missing something obvious, but I can't figure out what it is. Can anyone point it out to me? Pretty please? ^_^
Last edited by Mutive on Fri May 19, 2023 1:30 pm, edited 1 time in total.
Enjoy Eidolon, my free to play game at: https://mutive.itch.io/eidolon, Minion! at: https://mutive.itch.io/minion or Epilogue at: https://mutive.itch.io/epilogue

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Trying to figure out how to animate a thing...

#2 Post by _ticlock_ »

Mutive wrote: Tue May 16, 2023 10:53 pm My goal is to have a player click on a map, at which point there's an animation of the sprite moving from the starting location to the clicked on location.
A simple approach is to use ATL. For example:

Code: Select all

transform move_to_point(x0, y0, x1, y1):
    pos (x0,y0)
    linear math.hypot(x1 - x0, y1 - y0)/100 pos (x1,y1)
You can apply the transform inside a screen or directly in Renpy statement:

Code: Select all

label start:
    show hero at move_to_point(100, 100, 300, 300)

Mutive
Veteran
Posts: 344
Joined: Tue Nov 21, 2017 2:23 am
Completed: Eidolon, Minion!, Love Furever, Epilogue
Contact:

Re: Trying to figure out how to animate a thing...

#3 Post by Mutive »

Thank you so much! I think that'll do the trick. (I need to fiddle around a bit more with the coordinates, etc, but I think I can make it work! Much appreciated!
Enjoy Eidolon, my free to play game at: https://mutive.itch.io/eidolon, Minion! at: https://mutive.itch.io/minion or Epilogue at: https://mutive.itch.io/epilogue

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot], Milkymalk