vjodar / gauntlet

OSRS Gauntlet Demake in 2d
3 stars 0 forks source link

Optimization #8

Closed vjodar closed 2 years ago

vjodar commented 2 years ago

Currently, if a player opened enough rooms, the amount of entities the game is updating and drawing every frame begins to slow FPS. On my machine, this happens at ~350 entities. One optimization could be a 'draw distance' feature where, if an entity is sufficiently far from the player/camera, it wouldn't be drawn at all.

vjodar commented 2 years ago

Commit #47: implemented "draw distance" feature where by entities that are more than 1 room length from the player's position don't get drawn or updated. This improves the amount of entities my machine can handle before dropping below 60FPS from ~350 to ~450.

vjodar commented 2 years ago

As of commit #61, my machine was able to handle the entire generated dungeon with >520 entities at ~58FPS. This may have been due to lowering the draw distance and basing the draw distance around the camTarget instead of the Player itself.

As the boss will now be fought in a separate room, performance should be good for now. But might re-open this issue if any other performance issues arise.