← Back to team overview

logame team mailing list archive

New Level loading and Tiling engine

 

Hi all,
I have recently committed large changes to the way levels are loaded and
introduced a tile engine which draws tiles to the background, so I
thought I had better explain how it works.

The information for each level is taken from two files; a single game
wide tiles.yaml file that lists each type of tile's characteristics and
its image file, and a specific level.yaml file.  All tiles used in the
game must be listed in tiles.yaml so the game knows about them.  At
present there are only 3 test tiles (red,green and blue).  Each tile has
a .png image which needs to be in media/images/tiles/ and can be any
size.  Each tile also has some characteristics listed in tiles.yaml,
such as whether it is solid (can be walked on, but not through) or not
(background decoration tiles or things like water) and if it is safe or
deadly (like water or spikes).  If anyone has any more ideas for other
characteristics, please shout:)
Collision detection between the tiles and player_1 is detected, but I
still need to write the code that will use it together with the tile's
characteristics, to act on the player.

The level.yaml file (only testlevel.yaml at present) holds all data
about a level, its name, the path to the background image, the tile
types used in the level with their positions on the background image,
and the enemies and collectable types, positions and other data.  This
file is hand editable, but listing the locations of all tiles, enemies
and collectables by hand would be nearly impossible for a complex level,
so my next task is to write a level editor that will create/modify
level.yaml files. 
I will also add some more documentation to these files so they can be
more easily understood.

A new Tiler class handles all the loading of the tile data and the
creation of Tile instances.  The images of each tile are then blitted
onto the background surface once only, during the creation of the level.

Any comments, bugs etc.. :)

Paul




Follow ups