B
babydoll
Guest
Hi, I thought I would get a quicker response posting here than on the youtube video for the Complete Platformer Tutorial part 1.
I completed the my first game tutorial and managed to iron out every little glitch I game across as I went along... but this one I cannot figure out the problem
It was working fine as we coded the left and right movement, and my player was moving fine. Then we added the horizontal collision and she hasn't moved since. She has a lovely walking animation (that I'm yet to learn how to assign to movements etc!) but keyboard left and right don't move her. I decided to finish the tutorial and have double checked all the code is in correct. She won't move or jump, at all. No matter what key I press. and I cannot for the life of me figure out what I've done wrong. Here is my step code:
//Get Player Input
key_left = keyboard_check(vk_left);
key_right = keyboard_check(vk_right);
key_jump = keyboard_check_pressed(vk_space);
//Calculate Movement
var move = key_right - key_left;
hsp = move * walksp;
vsp = vsp + grv;
if (place_meeting(x,y+1,obj_wall)) && (key_jump)
{
vsp = -7;
}
//Horizontal collision
if (place_meeting(x+hsp,y,obj_wall))
{
while (!place_meeting(x+sign(hsp),y,obj_wall))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;
//Vertical Collision if (place_meeting(x,y+vsp,obj_wall))
{
while (!place_meeting(x,y+sign(vsp),obj_wall))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
I completed the my first game tutorial and managed to iron out every little glitch I game across as I went along... but this one I cannot figure out the problem
It was working fine as we coded the left and right movement, and my player was moving fine. Then we added the horizontal collision and she hasn't moved since. She has a lovely walking animation (that I'm yet to learn how to assign to movements etc!) but keyboard left and right don't move her. I decided to finish the tutorial and have double checked all the code is in correct. She won't move or jump, at all. No matter what key I press. and I cannot for the life of me figure out what I've done wrong. Here is my step code:
//Get Player Input
key_left = keyboard_check(vk_left);
key_right = keyboard_check(vk_right);
key_jump = keyboard_check_pressed(vk_space);
//Calculate Movement
var move = key_right - key_left;
hsp = move * walksp;
vsp = vsp + grv;
if (place_meeting(x,y+1,obj_wall)) && (key_jump)
{
vsp = -7;
}
//Horizontal collision
if (place_meeting(x+hsp,y,obj_wall))
{
while (!place_meeting(x+sign(hsp),y,obj_wall))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;
//Vertical Collision if (place_meeting(x,y+vsp,obj_wall))
{
while (!place_meeting(x,y+sign(vsp),obj_wall))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;