M
Morfic
Guest
Hi all. I am new to programming, and this program. I have an object that follows the mouse cursor position at a certain speed. That object can jump when I left click, and it obeys gravity and vertical collision.
However, for some reason the object walks right through horizontal walls. Is there any pointers you could lend me? Heres my code:
However, for some reason the object walks right through horizontal walls. Is there any pointers you could lend me? Heres my code:
GML:
//Get Player Input
mouse_jump = mouse_check_button_pressed(mb_left);
//Calculate Movement
hsp = move_towards_point(mouse_x,y,4)
vsp = vsp + grv;
if (place_meeting(x,y+1,oWall)) && (mouse_jump)
{
vsp = -7;
}
//Horizontal Collision
if (place_meeting(x+hsp,y,oWall))
{
while (!place_meeting(x+sign(hsp),y,oWall))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,oWall))
{
while (!place_meeting(x,y+sign(vsp),oWall))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
Last edited by a moderator: