Sprint 3 just ended for our FYPs (Final Year Project) so I figured I’d talk a little about my main focus for this sprint.
My initial goal was to have all my Scene objects loading from xml files. While I didn’t get to fully complete this goal before the deadline, I did get pretty close: close enough to complete it before Sprint 4 starts. As it stands, I have the SceneProxy
written to allow lazy loading of the Scenes themselves from xml files, but the class can’t be used with my SceneManager
until I have Menu scenes loading from xml (currently I only have Level scenes loading from xml).
I have 3 layers of xml loading in my game now. Layers might not be a great word for it but it helps to explain how it works. The first layer is the Level constructor; It takes a tinyXML2::XMLElement*
, “<Level>
” surprise surprise, and initializes its members from the tag’s body. It’s simple and straightforward until you get to the <Units>
tag, whose body is filled with <Unit type="xyz">
tags. Each <Unit>
tag denotes a single Pawn
(Minion
or Hero
) to populate the level with. A UnitFactory
takes the type attribute and returns the created Pawn
.
The UnitFactory
is where the second layer becomes involved. The type attribute of each <Unit>
denotes the file name for the unit definitions (minus the extension). The factory opens the corresponding file and passes the first xml element to the Minion
or Hero
constructor. Within the root element are is the <Pawn>
element, and inside that is the <Actor>
element, which in turn contains the <Collidable>
element. Each of these are passed to the corresponding constructor, which initializes its member variables and passes the base class tag to base constructor.
The third layer comes into play in the Actor class. The <Actor>
xml tag contains none or more <Animation>
tags. I have written a specialized template for my ResourceManager
to work with thor::FrameAnimations
, so the ResourceManager
can load each unique animation once and each Actor
can hold references to the ones it needs (inside its thor::Animato
r).