#### Archived

This topic is now archived and is closed to further replies.

# Collition Detection in Tilebased games

This topic is 5410 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How would i best test if a thing is colliding ? Right now i store it like this: Each tile can be blocked or not blocked. A list of characters. A list of other objects. Is this a good way ?

##### Share on other sites
One of two ways:

* Move them all then check their boundaries against each other one at a time and adjust objects that collide
* Detect early for collisions and move every object forward to their adjusted positions.

Tile games could just compare square shapes against square shapes. It''s easy to check collisions between squares. You just compare x and y values between the squares to see if the limits of one are within the limits of another.

##### Share on other sites
Depends on how things are stored, in my tilebased strategy game I just check to see if the tiles army index is 0. Meaning it empty or if it has value that means there is an army there.

-----------------------------------------------------
Writer, Programer, Cook, I''m a Jack of all Trades
Current Design project
Chaos Factor Design Document

##### Share on other sites
when you build the tile struct, you can includes a boolean value, it can determine the tile is blocked or not.

e.g.
struct _tile_info{
int x, y;
bool isBlocked;
......
}tile_info;

Then, you check the tile_info.isBlocked each time to see whether it is blocked.

##### Share on other sites
So you store each charaters blocking in the tilemap ?

or what ?

##### Share on other sites
I have my code set up to prevent two objects from being in the same tile.

-----------------------------------------------------
Writer, Programer, Cook, I''m a Jack of all Trades
Current Design project
Chaos Factor Design Document

##### Share on other sites
In my tile game I have a couple of object layers:

- building
- land unit
- naval unit

I store the object number (ie: unit number, building type) in it and set it to zero if empty. So I just check if object = 0, if true it''s empty on that layer.

##### Share on other sites
well i use to build a tile base gamed on a low ended machine like my belover casio scientist calculator graph 80 with 64ko

all object was store in a 2D array (matrix)

then i have just to translate the content of the array into screen graphic

when i have a unit move i only test the square content in his front if it''s a id of field then made calculation with it (if ID is xx then find the event script with it)

i have many layer too by using a tricks, i use last number of a numeric value as ID for the field and first number as ID fort object)

it''s very effective and fast (since i was on a low end machine)
and i was allow to build a strong ai within it in a action and platform game

>>>>>>>>>>>>>>>
be good
be evil
but do it WELL
>>>>>>>>>>>>>>>

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631428
• Total Posts
3000027
×