Skip to main content
gamedev.net
🔒 Locked

drawing borders

Started by alex mcandrew 4 replies 1.4k views
Original Post
alex mcandrew
alex mcandrew
Hi all, I'm working on a 2D tile-based (not isometric) turn-based strategy game. I need to draw borders between players' territory and enemy territories. First of all, I'm not sure what the best way to store this information would be. I could either (1) store all of the tile IDs that belong to each player. The other option (2) is storing the tile IDs of the tiles that are on the border. With option 2, however, how could I then determine which tiles belong to which player? I assume the second option would be easiest for drawing the borders, but how could I determine where the borders are to be drawn if I go with the first option? [edited by - alex mcandrew on January 30, 2004 12:02:01 PM]
alex mcandrew
alex mcandrew
The only thing I''m worried about with this option is slowing things down too much. A normal map will be about 6000 tiles. Using this option would force me to check every tile, plus check each tile''s neighbors. I imagine that this would take a great deal of time.
Does this seem like a valid concern?
Sam Gamgee
Sam Gamgee
Another option then is to perhaps have a Tilemap (option 1) where a value of 1 is player1''s territory and 2 is a border of player1s. Than 3 is player2''s and 4 is player2''s border and so on. I used something similar in Hands to Quarters which has up to 19000 tiles and it works great.

Anyway, sorry for the short reply, but I''m in a hurry.

Walter O. Krawec Games
www.waltsgames.com
TANSTAAFL
TANSTAAFL
store within the tile the id of the player who "owns" the tile, which i presume will determine what color the border shall be drawn in.

also store within the tile a number where one bit represents a side of the tile. in a square, this would be one bit for north, one for east, one for south, and one for west. since this is only four bits, you may want to also put the playerid value with it together into a single byte (if you know that you''ll have less than 16 players, because 0 will be reserved for "not claimed")

when evaluating a square for which borders to show, simply check the playerid values in each of the squares it shares a border with, and store this information in the border variable. when creating a new map, you will only have to do this one time.

when the ownership of an area changes, then you need to reevaluate that area, and each area that it shares a border with. if using squares, that means only 5 evaluations, rather than having to do the entire map each time.
Get off my lawn!
alex mcandrew
alex mcandrew
Thanks both of you. I''m goign to try what TANSTAAFL suggested, sounds like a pretty good approach. Trust me when I say that I will be back with any question.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.