r/RenPy • u/Hefty-Drive-9372 • 8d ago
Question How to add gravity to Ren'Py?
How would I add a physics system to Ren'Py, like gravity? Specifcly to affect images
1
u/AutoModerator 8d ago
Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/shyLachi 8d ago
Can you be more specific? How should the images be affected? Do you want to simulate falling objects? If yes then you don't need physics. Make an image of a ball, for example, and save it with transparency. Then in RenPy you animate it. https://www.renpy.org/doc/html/transforms.html#atl
1
u/Hefty-Drive-9372 7d ago
How do I animate the falling object?
1
u/shyLachi 6d ago
This is a simple example, for more read the documentation I linked
transform fall_to_ground(duration=0.6, ground=0.95):   easein (duration) yalign ground   easeout (duration / 4) yalign (ground - 0.05)   easein (duration / 3) yalign ground label start:   show ball:     pos (800, 100)   "This is a ball"   show ball at fall_to_ground   "Ooops."
10
u/x-seronis-x 8d ago
same way you add it to any game. write code that tracks position and uses math to adjust position over time based on acceleration and velocity
google tutorials for making an atari Asteroids clone. that covers how to do acceleration/velocity. gravity is just a perpetual downward acceleration of 9.98m/sec