After tiles, the other visual component of a 2D game is sprites. They resemble tiles in a lot of ways and are rendered almost identically, but there are important differences:

  • They are not placed on a grid, but at arbitrary (x, y) positions.
  • They can be any size (though I am using only multiples of the tile size).
  • They can be animated and moved by the game engine.

The last point is the tricky one. How exactly should that work? When placed in the editor, sprites belong to a room, but in the game they aren’t necessarily going to stay in there. Also, for purposes of loading and saving the game state, dynamic data has to be outside the level structure entirely. Should sprites be turned into Actors (see previous post on Game Objects)? Perhaps, but most of them are only going to interact with the physics system, and not do anything special.

The simplest solution is probably the best. On initialisation I copy the sprites into the game state, with an optional link to a physics object, and render them from there.

Now I have crates! Surely the most ubiquitous game object of all time.

Advertisements