Login | Register

Platformer collision problem

fishy

Andrew

Member
Posts: 1
1.
fishy at February 7, 2009, 20:48
Hi all.

I've come across a collision problem with my platformer that I've not seen anyone else have. What seems to be happening is that when the player jumps, he/she lands one pixel above the ground. The weirdest part is, it doesn't happen all the time. In fact, it very rarely happens. The main times I've seen it happen is when the player's not moved left or right yet.

Instead of c&ping all the code, I'll just give you the basic engine:

http://www.sendspace.com/file/5oaaul

(Arrow keys to move, X key to jump.)

Try running the game and jumping straight away at full height (hold down the X key), without moving first. You'll see that you land one pixel above the ground. However, if you jump again, you'll land fine. Then, the next time you jump, you'll land one pixel short again, etc.

I'm confused.

By the way, I'm using Pro and apparently I've used a function which is Pro-only. I think it's the xscale variable, but I'm not entirely sure (if it isn't, someone let me know what it is). If it is, just go to obj_player's Step event, scroll down and find this paragraph of code...
// sprite
if face = 1
{
image_xscale = 1;
}
if face = 2
{
image_xscale = -1;
}

... and delete it. If that doesn't work, please tell me exactly what the error message says. (I think you can just c&p it.)

~ fishy

PS: You'll probably notice that I'm currently using a room speed of 60, but I'm using 2 pixel horizontal movement and weaker jumps and gravity. Does this make the game run much smoother? Will it lag more/less? Should I just use a room speed of 30 and use 4 pixel horizontal movement and normal jumps and gravity?
if obj_you.action = piss_me_off
with obj_you instance_destroy(nuke)
.
Users logged in:

game maker articles, game maker examples, game maker tutorials, gmtutorials, game maker questions and answers, game maker crash course, how to create games