Sign in to follow this  
Krocman

Tile Map - Dealing with objects larger than a single tile

Recommended Posts

I'm developing a simple RTS game for an AI project I'm doing, and have been wondering how to handle units (mainly buildings) that are larger than a single tile. For simplicity, I have made all my units exactly one tile (64 x 64), however, some buildings are larger (128 x 128 etc). My tile map is a 2D array of tile structures. The map has multiple layers, one of which is devoted to 'storing' a unit or building on it. I thought about just assigning the top left tile of my building as the one occupied in the tile map, and the one containing the graphic to render, and then setting the other tiles as not passable to ensure my path-finding still works. This might have sufficed, however, my graphics won't be drawn if the top left tile is off the screen, even though the building should still be partially drawn... So I'm in need of a method of handling structures of sizes greater than a single tile. Any suggestions on how to manage units for each side (a container inside a player object of all that sides units and a reference to the tile they're on?) Having just typed this out, it's just occured to me that I should just use the tile map for pathfinding, and render buildings etc by working out if they're just visible, and obviously fixing their co-ords to valid tile ones? I think that would make more sense....

Share this post


Link to post
Share on other sites
I'd probably just split it up into it's tile components. So you'll have 2x2 tiles for a total of four tiles. Then on the tiles, just have them point to your actual building object, and have the game use those tiles to interface your building object when it's interacted with. Not sure if that's an optimal way, but that's basically one way of looking at it. It would help too when placing your buildings, because you have to make sure each tile is not blocked currently anyway.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this