Collition Detection in Tilebased games

Started by
6 comments, last by logout 20 years, 7 months ago
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 ?
Advertisement
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.
It's not what you're taught, it's what you learn.
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

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.


So you store each charaters blocking in the tilemap ?

or what ?
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

In my tile game I have a couple of object layers:

- road
- 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.
-----------------------------Empires! Visit online at http://www.daleszone.comProgramming for a funner world.
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
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>be goodbe evilbut do it WELL>>>>>>>>>>>>>>>

This topic is closed to new replies.

Advertisement