A
Alex hubbard
Guest
So I'm am currently learning the basics of coding, and have so far completed walk left, right as well as jump. And now I am trying to learn how to program the attack animation, nothing more. I would kindly appreciate some knowledge on the subject.
P.s I am very new to programming, so please if possible, it would be very helpful if you followed with an explanation as well. thank you kindly. coding script below
// get player input(Movment)
key_left = keyboard_check(vk_left);
key_right = keyboard_check(vk_right);
key_jump =keyboard_check(vk_up);
//Caculate mopvment
var move = key_right - key_left;
hsp = move * walksp;
vsp = vsp + grv;
if (place_meeting(x,y+1,objectW)) and (key_jump)
{
vsp = -7;
}
//horizontal collison
if (place_meeting(x+hsp,y,objectW))
{
while (!place_meeting(x+sign(hsp),y,objectW))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,objectW))
{
while (!place_meeting(x,y+sign(vsp),objectW))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
//Animation
if (!place_meeting(x,y+1,objectW))
{
sprite_index = sPlayerJ;
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;
}
P.s I am very new to programming, so please if possible, it would be very helpful if you followed with an explanation as well. thank you kindly. coding script below
// get player input(Movment)
key_left = keyboard_check(vk_left);
key_right = keyboard_check(vk_right);
key_jump =keyboard_check(vk_up);
//Caculate mopvment
var move = key_right - key_left;
hsp = move * walksp;
vsp = vsp + grv;
if (place_meeting(x,y+1,objectW)) and (key_jump)
{
vsp = -7;
}
//horizontal collison
if (place_meeting(x+hsp,y,objectW))
{
while (!place_meeting(x+sign(hsp),y,objectW))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,objectW))
{
while (!place_meeting(x,y+sign(vsp),objectW))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
//Animation
if (!place_meeting(x,y+1,objectW))
{
sprite_index = sPlayerJ;
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;
}