eforgacs-games / Dragon_Warrior

This is a clone of Dragon Warrior for the Nintendo Entertainment System, done in Python.
5 stars 2 forks source link

FPS improvements #19

Closed eforgacs closed 2 years ago

eforgacs commented 2 years ago

While the recent FPS increase has yielded a consistent frame rate of roughly 60 FPS, this is still inadequate to provide double speed and beyond. Further performance improvements are needed to improve the quality of play when playing at frame rates above the original NES frame rate of approximately 60 FPS. This is especially noticeable when walking on trees in Alefgard (the overworld) while double speed or above is enabled.

eforgacs commented 2 years ago

One way to approach this might be when assigning tiles to groups, get the tiles that are within vicinity of the player and add them to a group. In the main game loop, update this group as the player moves. This can be the tiles updated around the player (tiles updated around NPCs are a different story).

eforgacs commented 2 years ago

Creating a rect with the size and position of the camera, and checking tiles to see if they collided with this rect fixed many of these issues. Additionally, creating a rect that surrounds each character and checking those rects for collisions also reduced unnecessarily drawn tiles.