A nasty bug going around last weekend kicked my ass, so not too much to report:
Been making large architectural changes to clean up my object model, so that things like moving platforms can work correctly without too much hassle. In summary:
Previously, I had a Level class that contained all the important objects relevant to a game level. Some of these objects had ‘Runtime’ counterparts that you had to construct by calling a relevant method, for example:
Level.Entities contains LevelEntity objects, which have a GetRuntimeEntity method that returns a (Runtime) Entity object based on the LevelEntity. To call this method, you have to pass in a Game object.
There are some major problems with this approach – the need to call GetRuntime methods complicates iteration over these containers and means that Game objects have to get passed as arguments to basically any function that needs runtime objects, which is a tremendous hassle.
In order to address these problems, I’ve decided to split the Level class out into two objects: Level and RuntimeLevel. Level will contain only ‘design-time’ objects that have no dependencies on each other or on the Game object, while RuntimeLevel will be constructed from a Level by the Game and contain preconstructed run-time versions of all the objects from the Level. This will allow me to simplify lots of code by simply walking over the contents of the RuntimeLevel when I want run-time objects, and walking over the Level when I want design-time objects. It also nicely splits out some responsibilities – previously, Level had to subdivide objects like entities and geometry based on their boundaries, for efficiency purposes, which made the class far more complicated than was necessary for level editing. Now, that responsibility falls on the RuntimeLevel, so Level can just use a Dictionary to store its objects for easy lookup.
Regardless, I did get some additional functionality built since last week’s post. Here’s a video of two moving platforms following some simple paths I built using the editor’s node tools (you may notice some minor collision detection glitches; these are caused by the platforms having overlapping bounding boxes, and will be fixed by the move to a RuntimeLevel class.)





