soulweaver91 / project-carrot

Project Carrot, an open source spiritual clone of the Jazz Jackrabbit 2 game engine
https://carrot.soulweaver.fi/
MIT License
38 stars 4 forks source link

Fix graphic assets management #3

Open soulweaver91 opened 9 years ago

soulweaver91 commented 9 years ago

Currently, each actor manages its own graphic assets individually. Objects of same class read the same assets multiple times in memory, which is obviously a very bad idea.

To fix this, implement a graphics cache: once a level starts, find all objects that have been used and call a static graphics bootstrapping static method on each. Load one copy of each sprite at most even if it was requested from multiple different objects. Keep the sprites in memory until the end of level or end of game. The object constructors need to be adapted to this.

Also, while changing the way the graphics are loaded, externalize the previously hardcoded values from the code to data files (XML or equivalent).

soulweaver91 commented 8 years ago

Other than that level load time resource retrieval, the applicable animation states in the manifests should also be migrated off the arbitrary number values to something more legible. (for example: "states": ["jump shoot", "fall shoot", "jump walk shoot"])

soulweaver91 commented 7 years ago

This still seems quite troublesome after putting a lot of thought and trying a failed code experiment. Some pointers:

soulweaver91 commented 7 years ago

Note: the last point of the previous comment was mostly dealt with in one of the collision revamp commits.