This is a 2d tile based game engine and map editor. The game engine allows the user to create objects to interact with the player and other objects, and the editor makes it easy to create and edit maps. Games can be compiled both statically and dynamically. When compiled statically, all the map data is added to the executable, and when compiled dynamically all map data is read from map data files.
New maps can be created by pressing 'n' and specifying a map size and name. This creates the map files mapname.layer, mapname.map, and mapname.objects. The layer file is used for foreground tiles which are displayed over everything else. The map file is used for background tiles, and the objects file is used to store the initial position of game objects. When the map is compiled, object data is stored at the bottom of the object file. All the object values are stored in its object file. Below is the object file of a player which can move around and has animated movement:
movable: 0 solid: 1 animated: 0 selfMoving: 0 moveWithKeys: 1 wander: 0 movingSpaceX: 0 movingSpaceY: 0 movingDirection: 0 currentSprite: 0 animatedSpeed: 40 spriteOrder: 12,13,14,15,4,5,6,7,0,1,2,3,8,9,10,11 extraInfo: - path: - spriteSheetPlace: CharsetRed1.png sizeX: 64 sizeY: 64 spriteSheetSizeX: 256 spriteSheetSizeY: 256
Characters specifically use the spriteOrder field to store up, down, left, and right movement in groups of 4. For example, when moving up the order 12,13,14,15 is used from the spritemap to create a moving animation. In other objects, extraInfo can contain more info about the object, and can be used in the object's code. spriteSheetSize and size are used to calculate the position of a tile from the map when drawing objects. All tiles are resized to 32x32 when the game map is compiled.
There are 4 layer views which can be cycled through in the editor by pressing 'l': map view, layer view, object view and all view. When in all view the map cannot be edited. In object view, only objects can be placed on the map, and in map and layer view any tile can be placed.
When a new image is detected in the image source folder, the user is prompted to create an image profile. Image profiles contain the image size and the size of each tile in the image.
New game objects can be added to object.cpp. Game objects can have different properties, such as being able to move around, being solid, and have different events when they come in contact with other objects. Object properties can be set using the editor.
Game maps are loaded at startup, and then the active map layers are loaded in to the current map. Once the active map is loaded the layers are drawn, and the game timer starts. Every frame when the map is redrawn, all objects are check for updates. This includes collisions, and timeouts.
Next I plan on creating a simple menu interface that will go over the game window, and I want to also make the map move with the player instead of having it all constantly displayed. Eventually I would like to find the time to actually make a game using this.