Sunday, August 16, 2009

Roomy

While I deal with bugs not entrely related to the creation of the rooms themselves I should mention some of the engine I built before getting to this point.

The game is, ultimately, built on a grid map, a two-dimensional series of tile objects. Each tile has several different attributes; a ground color, a creature on it, a stack of treasure, and whether or not it can be passed over by a creature (which preempts having a creature on it, of course).

I decided to keep all the tiles in a one-dimensional array, for a specific reason I now forget, and use a function to calculate what the index of a tile at a particular X,Y coordinates is. So far, it's worked just fine.

Now, that means I'll have hundreds of tiles - heck, hundreds in each map - but I don't want to draw so many of them. Afterall, it's an isometric display, I can only fit about a ten by ten screen up at a time. So, based on the location of the player, I only draw the tiles, and the contents thereof, which are visible to the player. It does mean a lot of extra checks for tiles that aren't onscreen - but that's something I'll work out later. It's certainly more efficient than drawing the entire world every frame.

Now, the player has the world to walk around in, and while it's pretty dull before I put the dungeon on it, it's certainly servicable. Eventually, I'll need to have them connect to other maps, but I figure I can wait until I reach the second floor of teh dungeon to start worrying about that.

No comments:

Post a Comment