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. Main Menu Img

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).

Level One Img

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.

<!-- filename: levelOne.lvl -->
<Level id="1">
  <Music volume="50">./res/mus/level.ogg</Music>
  <Path>	<!-- nodes that enemies will follow through level -->

    <Units>	<!-- every unit in the level, including PC -->
       <!-- type attribute gets picked up by UnitFactory -->
        <Unit type="basic_enemy">
        <Unit type="fast_enemy">
	    <Unit type="hero">

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::Animator).

<!-- filename: hero.def -->
<Hero name="hero">
  <HealthRegen rate="100">1</HealthRegen>

      <!-- Texture path, this will be the texture's key in the ResourceManager -->
      <Animation path="././res/xml/hero_run.anim">
        <!-- Friendly name, local to each Actor -->
        <!-- Duration of animation in seconds -->

      <Origin x="25.f" y="50.f"/>

      Used to check for collisions.
      Options for type are "Circle" and "Convex";
      Circle requires a radius, whereas Convex requires the x, y and index of each point.
      <Collidable pointCount="6" type="Circle">
        <Offset x="-2.5f" y="-5.f"/>

Level One Img