Just looking for a quick advise on Ground collision for a basic
2D Platform Game.
For a flat surface it is easy to check collision as we only need to
check for Rectangle to Rectangle Collision like on this picture:
But how would you do that when level ground is
not even, like in this picture:
So, if anyone has a good advice on how to approach this, please let me
know,and i am sure it will be helpful not just for me.
Thanks a lot for your time.
Please log in or register to post a reply.
In Worms type games you generate a monochrome bitmap where black
represents ground or obstacles and white represents open space. You then
perform pixel checks in the monochrome bitmap to find the floor or
obstacles. If your game is a side-scroller, you can save considerable
memory by just storing a single Y-value along the x-axis, which will
represent your floor. It’s a very fast look-up formula f(x) = y. You can
use standard sphere or box collision tests for the other entities in the
I’ve never done this. You could do a search for per pixel collision or
maybe someone here can explain it.
Or you could divide the terrain into smaller sections of straight line
slopes. Each of these smaller sections would comprise a rectangle. The
straight line between the lower corner of the rectangle and the upper
corner of the rectangle would have a slope, so you could use y=mx+b to
find a collision point in between after first testing for rectangular
Hmm. theNut beat me to it. So that’s per pixel.
Hey. This is my first post here, so don’t mind me if my post is stupid.
I did a technique like TheNut, where you have a single image
representing the level collision data, which isn’t the normal level
‘color’ data. Then, you check each pixel to see if its alpha is greater
than 0 - if so, then there’s ground or a wall in that position.
Then you could make the sprite escape to the closest possible position
that is in air, and that would work for caves, walls and the ground yes.
Ive actually done that before myself also.
I like your wicked trees btw.. :)