As a kind of mental exercise I have started working out a design for a 2D game engine. I have choosen three primary goals for the design:
1> The system must be able to have the rendering code layer completely replaced without any code changes. For instance I would like to be able to have LWJGL, JOGL and Java2D versions of the rendering layer.
2> The code (related to the library) for a game should be very easy to read and understand.
3> A java programmer just starting to get into game programming should be able to get something on screen in under an hour.
The current class diagram, such as it is, can be viewed here.
I’m interested in hearing opinions/advice on the design. A little background should help (an example program provided below):
GameCore - This abstract class is the center of the world for the library. Each rendering layer will have to implement a version of this class. Some methods common to every rendering layer are provided. The factory methods for creating different kinds of game objects will be filled in by each implementation. This object hides the specifics for any given type of rendering, OGL, Java2D.
GameCoreProgram - This interface must be implemented by the game.
DisplayObject - All classes that place something on the screen must subclass this class.
RenderList - A list of DisplayObject objects. Can use Z sorting to order the items drawn to the screen.
RenderSet - A list of RenderList objects. RenderSets are the only objects allowed to be passed into the GameCore rendering method.
org.gamecore.event.* - The classes in this package are used to avoid the AWT/Rendering thread issues. The rendering layer GameCore implementation must handle all events and place them into the GameCoreEventQueue. The programmer then deals with the events inside of the rendering thread.
Currently I’m having trouble trying to figure out how to abstract out the canvas that will be drawn to. Any help here would greatly appretiated.