Okay, so I'm trying to render a map composed of small tiles. My character is fixed on the center and the map moves smoothly below it. The problem is every time the render method is called it checks if an animation is happening and call a 'change_pos' method, that updates the position of all my tiles. With a 10x10 grid I have no performance problems, but as the number of tiles grow, my game starts to be laggy - which is, honestly, expected.
I'm using the same image object for the same type of tile, so it's not a RAM problem, since it loads just 5 or 6 different small images. I tried to check if the image should or shouldn't be rendered by checking its position with a xmax, xmin, ymax, ymin (my print zone is 3 times width and height of the screen) in the case the problem was the rendering itself, not the checking method, but it's still laggy.
I would like to know if there is a better way to calculate positions and/or render all those images without lag. Maybe using a well optimized renpy function, or even threads (haven't found much about this on the doc).
How to render a lot of small images without lag
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.
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.
- PyTom
- Ren'Py Creator
- Posts: 16094
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: How to render a lot of small images without lag
This is basically the use case Ren'Py's SpriteManager class is designed for. Check it out.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Who is online
Users browsing this forum: Google [Bot], Yone28