A
arekkusu
Guest
Hello, I'm new to programming and really need help.
I'm making a platformer and I'm having a problem inserting an additional run animation for the left direction. I made the sprite run to the right, even jump rightwards, but can't seem to do the same for the other direction without canceling the previous script.
All that is on the player object.
I'm making a platformer and I'm having a problem inserting an additional run animation for the left direction. I made the sprite run to the right, even jump rightwards, but can't seem to do the same for the other direction without canceling the previous script.
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,o_wall)) && (key_jump)
{
vsp = -7;
}
//Horizontal Collision
if (place_meeting(x+hsp,y,o_wall))
{
while (!place_meeting(x+sign(hsp),y,o_wall))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,o_wall))
{
while (!place_meeting(x,y+sign(vsp),o_wall))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
//Animation
if (!place_meeting(x,y+1,o_wall))
{
sprite_index = sPlayerA;
image_speed = 0;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}
else
{
image_speed = 1;
if (hsp == 0)
{
sprite_index = s_player;
}
else
{
sprite_index = s_playerR;
}
}