ikbensiep / lofigame

A 2D game without canvas, only html vibes. SVG is used not only for artwork but to annotate as much world/level data as possible, simply by drawing shapes accoring to a few rules. Exploring wether it's worthwile to make it into an open source 2d world game engine.
https://ikbensiep.github.io/lofigame/
GNU General Public License v3.0
1 stars 0 forks source link

Sh/performance: sprite positioning #42

Closed ikbensiep closed 5 months ago

ikbensiep commented 5 months ago

Closes # 41 (issue in wrong repo..)

Essentially comes down to only drawing / updating positions when dynamic items are actually in view.

Most prominent example is the waypoint markers.

The frame drop was caused by displaying racetrack waypoint # 1 which will end up being a far end away from the player and thus creating a large drawing canvas for the browser (even though I hid other waypoints, the next non-hit waypoint would always be drawn, and at this distance (1000s of pixels away) that becomes a large paint call.

Now, I'm calculating if waypoints and marshals are actually (almost likely soon) within the screen, and if not, simply either not draw or update their position.

This might even be improved by doing the same for tree, tire track and smoke sprites, but for now the gains are already significant.

Cheers everybody, good work, drinks on me :beers: