Level Design of Legend of Tux

From LD Smith Games Wiki
Jump to navigation Jump to search

General Process

  • Create tile data and enemy data arrays
    • Create tiles/collision block data
    • Add enemy data; The enemy data array only contains the starting location for enemies. Advanced AI will be added in a later release of the game.
  • Make the level selectable in the lotux.c file
  • Add mappings in the file_read.c file, in the "getMapArray", "getCollisionMapArray", and "loadEnemiesArray" for the level to the arrays defined in the maps.h file. The arrays in maps.h are named levelX_Y_mapZ, where X is the level number, Y is the room number, Z=0 for the collision/title array, and Z=1 for the enemies array. In the future, there may be a separate tile and collision array, for invisible walls, but at the game's current state I am just making all walls impassible
  • Modify the bkg.bmp, block01.bmp, block01_00.bmp, block01_01.bmp, block01_10.bmp, and block01_11.bmp files in the "images/level" directory (where "level" is the name of the level, such as astro, bolt, flame, etc). Use gimp set the background image in bkg.bmp, and make the block01 files have a color scheme appropriate for the level, such as make the blocks a dark red color for the flame world. Ensure that there is a high contrast between bkg.bmp and the block01 files, so that the user is able to clearly distinguish the background from the impassible wall blocks.
  • Add music for the level, and enable the music in the lotux.c file

Creating the tile data

Download Mappy: http://www.tilemap.co.uk/mappy.php

Extract the zip file to a directory

Start Mappy

Select File => New Map

Use the following settings

Mappy001.jpg

Press "OK"

Press "OK" to the warning

Select File => Import

Navigate to the project directory, and select the "tiles.bmp" file in the images directory

(Use Gimp to modify the tiles.bmp file to add new tiles, if needed)

Ensure that Layer 0 is selected. Layer 0 will hold the collision block data

Mappy002.jpg

Select the second block (1/64), and use it to draw the collision blocks. Make sure the whole room is enclosed, and leave an empty space to join to the next room. If the is not the first room, make sure to leave an empty space aligned with the door from the previous room.

Use the "f" key to flood fill tiles; "z" key to undo mistakes

Mappy003.jpg

Use the third block to draw the door, which will be removed once all enemies are defeated. So far, I have been using blocks locations 31,9 through 31,13 for the door. Make sure blocks 0,9 through 0,13 are empty in the next room, otherwise the player may get stuck in the wall when zoning into the next room.

Mappy004.jpg

Select Layer => New Layer

Ensure that the New Layer is selected

Select Onion Skin

Mappy005.jpg

Check "Enable Onion Skin" and ensure that Background Layer is set to 0

Mappy006.jpg


Use block 1/64 to set the starting enemy location. Currently, the game only has one type of enemy. However, in the future we may use other tiles for different enemies. You may also want to use a different sprite sheet for enemies.


Mappy008.jpg


File => Save As

Navigate to the "maps" directory. Save the map as "levelX_Y.FMP" where X is the level number and Y is the room number.

Mappy009.jpg


File => Export as text

Use the following settings. Ensure that "Prefix with" is set to "int"

Technically, I believe "const" is a C++ keyword, which is why I suggest removing "const short" for int. However, gcc in cygwin seems to have no problems compiling a C program with C++ notation, such as // for comments (which I use all over the program). However, compiling this program with an older C compiler may throw warnings or errors with C++ syntax such as "const" and "//".

(Colour Map can be unchecked, but it won't hurt anything to leave it checked)

Mappy010.jpg

Press "OK"

In cygwin, navigate to the project directory.

Copy the txt files that were exported in mappy from the level directory up to the maps directory. Chmod the TXT files, otherwise they can not be appended to the maps.h file using the makeheader shell script

Go to the "maps" directory, add "cat levelX_Y.TXT >> maps.h" to the file, run makeheader, and copy the maps.h up to the project directory

 # cd maps
 # cp level/*.TXT .
 # chmod u+rw *.TXT
 # vi makeheader ; echo "Add append code to script"
 # ./makeheader
 # cp maps.h ..


Edit the file_read.c file and add mappings for the new level. Hopefully, I will have time in the future to figure how to simplify this process so the three huge switch statements aren't needed.

Finally, recompile the program files and test.

Level Testing

General problems to look for:

  • Rooms without any enemies; The door will never open, since the code to open the door is only checked when an enemy dies
  • Missing room arrays; will usually cause the program to exit when the missing room is entered
  • Rooms that have no way to exit; The wall prevents the player from getting to the door, or prevents the player from being able to kill all the enemies