Y
Yoo
Guest
Hey, again with the platform game. So I've managed to work out the vertical collision for jumping, but the horizontal is a bit tricky. It works but sometimes object will step a bit into the wall and maybe even cause problem with jumping later... probably because of the vertical collision. Also when that happens (sometimes), I am able to stick my object sideways, while in the air into the wall... as long as I am holding the directional key. Maybe it also has something to do with sprites and masking, but I just wanted to check if maybe it's something with the code:
Movement code i used:
if keyboard_check(ord("D")) hspeed = 20;
if keyboard_check(ord("A")) hspeed = -20;
if (speed > 15) speed = 15;
friction = 6;
Collision code:
if(place_meeting(x+hspeed,y,Object_Wall))
{
while(!place_meeting(x+sign(hspeed),y,Object_Wall))
{ x += sign(hspeed); }
hspeed=0;
}
x += hspeed;
Thanx in advance.
EDIT: I get the feeling like the object gains in speed at some points, and just rams through the wall...
Movement code i used:
if keyboard_check(ord("D")) hspeed = 20;
if keyboard_check(ord("A")) hspeed = -20;
if (speed > 15) speed = 15;
friction = 6;
Collision code:
if(place_meeting(x+hspeed,y,Object_Wall))
{
while(!place_meeting(x+sign(hspeed),y,Object_Wall))
{ x += sign(hspeed); }
hspeed=0;
}
x += hspeed;
Thanx in advance.
EDIT: I get the feeling like the object gains in speed at some points, and just rams through the wall...