Reinventing the wheel
Friday, July 21st, 2006It’s interesting: I learned SDL game development a while back. While learning it, I developed my own model for a graphics memory manager and draw-images queue.
Now I’m working on a Java2d game engine with a lot of similar features. I’m finding that more often than not, the features are best implemented in nearly the exact same way. I’ve done a few changes to my graphics manager and the model of graphic storage for better image ordering and management.
With graphics, in my SDL graphics manager I stored graphics in the graphics manager, and when an entity needed to draw a graphic, it would pass in the x and y coordinates of that graphic, and a reference to that graphic, and ask the graphicsManager to draw it. This works fine for drawing sprites, but what if I wanted to draw a more complex visual but use the same source image? For example, animations, color shifted images, blurring, a combination of two images through a filter?
Now, each entity contains a “VisualRepresentation” class. This class contains the reference to the immutable loaded image , and when I ask the VisualRepresentation to draw, it will allow the graphics manager access to this instance’s properties. The VisualRepresentation contains only state information relevant to rendering and not information about the entity itself.
BlockGrab has been released. It can be found