There’s a Hole in the Roof

   UPDATE: Okay so I underestimated the complexity of this system I described below. Even when it looks done, the player’s head is cut off when he’s under a tree and the rest of his body is in front of a tree trunk. I’m going to work on a different system which will use midlines. What I mean by midlines is that certain tiles’ transparency map tile will be set to 1. This will tell the code what tile to check during Draw. If the player’s Y value is above this tile, then the player character will appear below it. If it is below, it will apear below. I believe this is a simpler, yet still complex system. It is also easier to code.

   Tackling layers was hard enough, but now I need to render the player character in betweeen multiple layers. Since the player character is 50*85 pixels, and the tiles are 32*32, this isn’t going to be easy. The problem with theoretically infinite layers is that there still has to be a set way for the player to render above or below tiles, regardless of layer. The most common example is the tree. For the tree, you want the player to appear above the tree trunk – but you also want the player to appear below the tree top. This illusion of 3d causes problems in the game code.

   Right now, I have it where the player is drawn after the 3rd layer is drawn. Suppose there’s a tree on the 3rd layer: should the player be drawn over top of it? Well, certain parts of the player sprite should, and other’s (the parts that are under the tree top) shouldn’t. In the current code, the player is treated like another layer and is drawn on top of the 3rd layer, regardless of logic. This caused me to realize the need for an intermediate layer: a layer that is drawn on top of tiles while simultaneously drawn below tiles when need be. The player character is a sort of “intermediate” or transparent, layer. It has no relation to the layers’ ordering when it is drawn.

   Of course, to implement this, I need to tell the game which tiles are to appear over the player, and which are to appear under. To do this I’ve created an extremely simple tileset map generator. This generator loads a map (like seen on the right side of the tile editor), and allows the user to draw a rectangle. Inside the rectangle the value of the tile(s) selected are displayed on top of their respective tiles. The user only needs to use the arrow keys to change the value from 1 to 0 or vice-versa. The result is sent to a textbox, which convienently puts the map in code form. From here the map can be copied directly into a new int[,] variable.

   Of course, this is the simple part, but it’s a step forward. When all is said and done, if there’s a hole in the roof, the player will appear under it, not over it.


~ by IG on June 18, 2008.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: