Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Help on collission detection fro a paltformer.

Author
Message
Dextro
21
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 13th Feb 2007 05:09
Hello.
I've been trying to come up with some formulas for collision detection between a sprite and a tile, but I haven't figured out how to do it in an effective manner.
Anyone got some knowledge about this? I will greatly appreciate it.
Thanks.
Dextro
21
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 13th Feb 2007 15:41
Ok, I have an idea that may work.
Basically, my idea consists on checking if the pixel below the player belongs to a solid tile, which is defined in a second array apart from my map array.

y1# is the y position of the player.
x1# the x position of the player.
roundup is a function for rounding numbers upwards.
For left and right collision I would use the same function, only changing x1# parameters.

Would this work?
Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 13th Feb 2007 20:13
Thats the main idea, work it out good enough and you'll have your collision ready.
A tip, if you're gonna use shaped tiles, say for example a ramp, if the tile returned was a shaped one, go to the array wich stores information regarding that, and other shaped tiles. What information?, well, for example that at X position within that tile corresponds Y. Get the idea?, when your in the tile, at x=4 (example, and that 4 is within the tile, not regarding the screen/world/whatever...), the height/y ther would be, say, 2... and at x=7 , y=5... and well thats pretty much it.

If this of no use, well, it'll leave the record for others to read. If you know of a better way of doing it, then please state it and let me test it...

Further on my stuff at...
Dextro
21
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 13th Feb 2007 23:27
Nope, I can't get it to work.
I used a UDT for each tile, keeping it's x,y and image/mask.
Anyone got any ideas on how to check for y collision with a tile?
Dextro
21
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 14th Feb 2007 00:04
As simple as

Duh to myself
Thc03
22
Years of Service
User Offline
Joined: 19th May 2004
Location: Pavia - Italy
Posted: 27th Feb 2007 03:10 Edited at: 27th Feb 2007 03:15
Look at this:


Bye, Berserk.
.

Bye, Berserk.
.
aluseus GOD
19
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 27th Mar 2007 20:51
even better yet...

Login to post a reply

Server time is: 2026-07-05 01:12:26
Your offset time is: 2026-07-05 01:12:26