How to render a lot of small images without lag

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
Lord Hisu
Regular
Posts: 58
Joined: Sun Feb 11, 2018 2:31 am
Contact:

How to render a lot of small images without lag

#1 Post by Lord Hisu »

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).

Image

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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

#2 Post by PyTom »

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
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: Kocker