Image Collision

Blitz3D Forums/Blitz3D Programming/Image Collision

GIB3D(Posted 2008) [#1]
I'm working on a 2d sidescroller and I've ran into some collision problems.

How do you make a 2d image go up a 2d image of a slant or hill like / ?


Ross C(Posted 2008) [#2]
I think this is solved by moving your character firstly along the x axis, then checking for a collision, if one is found, then:

You will need to have some sort of a limit to the kind of slope the character can climb. Say for instance, he can only climb hills that go up 1 pixel and across one pixel, a perfect diagonal.

Move the character up one pixel, then recheck the collision. If one is registered, then you will need to either move the character up again, or move him back to his original position and say he cannot go any further as the hill is too steep.


GIB3D(Posted 2008) [#3]
Hiya Ross

If ImagesCollide(u\Image,u\X+x,u\Y+y,u\Frame,TileSet(t\TileSet),t\X,t\Y,t\Frame) = 1
		u\Vy = u\Vy - (u\Vy+Abs(u\Vx))
EndIf


It checks to see if the player is touching the image, if it is, the Y Velocity changes so the player goes up, except for it's bouncy. When the player hits the ground (There's no gravity yet so I have to hold the down button) he bounces up a little bit.

The player also goes through walls which I'm not sure how to change that without messing up the x velocity. The only way I can possibly think of is to check for image collision and if you are colliding, the x velocity goes to 0 or something like that. But that would also make the x velocity stop on floors too because the player goes through the ground a little bit.

The ground and walls have a wave to them. I just now looked at a screenshot of Super Mario World to see if the ground is the same way, and it's not... so I'm going to go ahead and change my tile set to not be way and be more perfect/straight ;) If you can help me with the above stuff that would be GRRRRREAT!


GIB3D(Posted 2008) [#4]
Does anyone else know much about 2D side scrolling? Please help.

Edit: How do you check "per-pixel"?


SytzeZ(Posted 2008) [#5]
Maybe you can, every time you collide, move it up pixel per pixel till it doesn't collide anymore:
While ImagesCollide( ... )
    u\y = u\y - 1
Wend


And for walls (X-collision) you could use another image, with the same system:
While ImagesCollide( ... )
    u\x = u\x - u\direction
Wend



GIB3D(Posted 2008) [#6]
Would it be stupid to just assign each non-black(the default masked color) pixel a type to do collisions?