U
Ursidae
Guest
Hi,
i'm pretty new to GMS2 and followed a Tutorial on Youtube. Now i'm stuck at changing sprites depending on what the character does. The Tutorial is about 2 Years old and i think they changed how things internally work...
Heres the code:
CREATE
STEP
Hopefully someone can help =)
Thanks
i'm pretty new to GMS2 and followed a Tutorial on Youtube. Now i'm stuck at changing sprites depending on what the character does. The Tutorial is about 2 Years old and i think they changed how things internally work...
Heres the code:
CREATE
Code:
hsp = 0;
vsp = 0;
grv = 0.1;
walkspd = 4;
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 * walkspd;
vsp = vsp + grv;
if (place_meeting (x,y+1,oWall)) && (key_jump)
{
vsp = -7;
}
//Horizontal Collison
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 Collison
if (place_meeting(x,y+vsp,oWall))
{
while (!place_meeting(x,y+sign(vsp),oWall))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
//Animation
if(!place_meeting(x,y-1,oWall))
{
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 = sPlayer;
}
else
{
sprite_index = sPlayerR;
}
}
Thanks