by DST » Wed Jun 18, 2008 11:22 pm
there are two ways to do collisions: Physical Response and Collision Free. Both have their advantages.
Physical response waits for a collision between two objects, then moves them outside of each other, while collision free is used to prevent collisions from ever happening.
an example for collision free is
if (CollisionFree("Event Actor", x, y+5))==0{y+=5};
This will cause a player to move down at a speed of five until something is in its way. This method takes some getting used to, but provides much more solid results than physical response.
The best way is a combination of the two. Since gravity must increase as a player falls, the landing spot can be unpredictable. If a player ends up 3 pixels above the platform, the collision free no longer equals zero and the player stops.
So what i do is use collision free for left to right movement, and physical response for up and down movement.
However, the shape of your actor is also a factor. Hey that rhymes.
If your actor's feet move all over the place, its hard to make good collisions. Remember how Mario was always a solid block, in a way? his feet were flat. that's very important. I am going to release a demo later today showing a good collision method.