top of page

C Level Parser Tool

Rapid Level Creation

My level parser tools works by creating a "tile" - a theoretical object that is placed into the world. Then, an ASCII character is used to override this block's visual, feeding it in a section of a trim sheet I build by aligned the tiles I needed for the Brinstar region. I built this level parser tool so I could generate a large scale of content for my project - and it paid off! I won 1 of 2 awards for the final project, with Metroid taking home the "Best Experience" prize.
 
This means that any room can be made by simply typing out a .txt file with the assigned characters in the Room.cpp file. Take a look at the first 2 rooms here!

notepad_RWqshhgOzu.png
notepad_bjRvhCBJGk.png

Corridor #1 and Fake Block Shaft

Below is an explanation and code sample of some of the relevant logic for generating each room.

First, take look at the constructor, specifically the first 2 lines which create a new room of the prescribed dimensions and pass in the tileSize value to scale the map correctly.

 

devenv_EYbNESbRb4.png

Inside of Room, I find the sprite atlas (in this case, Brinstar.png) to read in all of the possible tiles. This could be replaced with any .png file, and so long as it was correctly tiled you could use an entirely new art style instantly!
 

Brinstar.png
devenv_P8GEzyE6BE.png

Next, check pixel by pixel for where each "tile" ends - graphing each in-game tile based on pixel data from the sprite atlas. This is just a snippet of the switch, there are quite a few tiles!

devenv_DG0jkX7pWp.png

Finally, it calls drawQuad (OpenGL) to draw the Quad for each of our tiles - visually implementing the tile. Once the tiles are drawn, we check if they are solid in-game or if Samus can pass through them.
 

devenv_Mjd9HvVdKv.png
devenv_60GInGYWoK.png

In this section, I apply an ASCII character to denote what each tile is meant to be from the .txt file. This allows for extremely quick creation and editing of rooms as I only need to type the changes into the room.
 

devenv_qmuJQ2Q1er.png

Jack Leavey @ 2023 - All Rights Reserved

bottom of page