Collition Detection in Tilebased games
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 ?
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.
* 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.
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
-----------------------------------------------------
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.
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.
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
-----------------------------------------------------
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.
- 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.
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
>>>>>>>>>>>>>>>
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
>>>>>>>>>>>>>>>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement