#2293 - whodoo - Sat Feb 01, 2003 2:55 pm
Whats the best way of detecting collisions when making a platform game such as Mario?...
I tried to use tile collisions but if I use that I can?t have sloping hills and stuff...
is it better to use "linje-collisions"...that I put lines in the memory where I cant walk and see if my player cross thatlines like
/
P--/---
/
/
I can store my lines with 2 positions and just check if the player cross a line..
#2295 - ampz - Sat Feb 01, 2003 3:49 pm
Nah, just do pixel collisions (sub tile collisions).
Eg. look at the colors inside the tile. color 0 = free, the rest=collision.
#2299 - whodoo - Sat Feb 01, 2003 5:56 pm
thanks :)
#2416 - Francis Lillie - Mon Feb 03, 2003 3:04 pm
Alternatively, the way I do fine-tuned 2D collisions, which is quick and easy, is to store the extents of an object for each raster of it. Basically 2 numbers per row which describe how many pixels in from the left that row starts at and how many pixels from the right the row finishes at. Then, when 2 collisions boxes collide, with simple addition down the height of the 2 objects you can tell if they actually overlap at all. Okay, so for doughnut shappes, or shapes with colour 0 holes in it, it doesn't work perfectly as a collision method, but in general terms it works fine. This is also how I properly kern my strings when I display them as sprites :)
#2418 - ampz - Mon Feb 03, 2003 4:54 pm
He wanted collision detection for sloping hills and stuff.
#2419 - Francis Lillie - Mon Feb 03, 2003 5:01 pm
Yeah, I know he wanted to do slopes and stuff, which is just as easy, and a spin-off from what I said, by processing column extents, not row extents, and hey presto, a height map to use for collision, which is how a lot of old Sega Megadrive games did their collision, on a meta-tile basis. Then if there is too great a height distance between where you are and where you ideally will be then you get blocked. If not, you can walk safely. Still quicker than doing pixel checks.
#2757 - whodoo - Wed Feb 12, 2003 9:06 am
I m doing like this right now...I draw unvisible lines where I cant walk..like
/
______________/
so if I have e.g. a square in the air I have four lines around it.. each line has two 2d coordinates..
then I have a "line" between the players position and his old position the last frame..
then I just check if the player-lines intersects an other line...and if its intersect Im just moving the player like if I walk between p1 and p2 then I move the player to 'x'
x /
/\
/ \
p1--/----p2\
/
this works fine, I can have different "frictions" on the ground and slopes...but is there a better way?
#2758 - whodoo - Wed Feb 12, 2003 9:08 am
I m doing like this right now...I draw unvisible lines where I cant walk..like
/
______________/
so if I have e.g. a square in the air I have four lines around it.. each line has two 2d coordinates..
then I have a "line" between the players position and his old position the last frame..
then I just check if the player-lines intersects an other line...and if its intersect Im just moving the player like if I walk between p1 and p2 then I move the player to 'x'
x /
/\
/ \
p1--/----p2\
/
this works fine, I can have different "frictions" on the ground and slopes...but is there a better way?