R
Rhqusa
Guest
I'm trying to make a game but I cannot get the animations to work. I have the step event right here:
And here is my create event:
I really need help, as I am new to GMS 2 and do not know how to handle animations yet.
The sprite itself has 20 frames (4 walking frames for each cardinal direction [the first 16 frames] and 1 idle frame for each cardinal direction [the last 4 frames])
Code:
/// @description movement test
var hinput_ = keyboard_check(vk_right) - keyboard_check(vk_left);
var vinput_ = keyboard_check(vk_down) - keyboard_check(vk_up);
if vmove_ > 0 {
hspeed_ = 0
} else if hinput_ != 0 {
hspeed_ = hinput_ * 3
hmove_ = 1
} else {
hspeed_ = 0
hmove_ = 0
}
if hmove_ > 0 {
vspeed_ = 0
} else if vinput_ != 0 {
vspeed_ = vinput_ * 3
vmove_ = 1
} else {
vspeed_ = 0
vmove_ = 0
}
direction_ = round(direction/90)
if place_meeting(x+hspeed_, y, o_solid){
while !place_meeting(x+sign(hspeed_), y, o_solid){
x+= sign(hspeed_)
}
hspeed_ = 0;
}
if place_meeting(x, y+vspeed_, o_solid){
while !place_meeting(x, y+sign(vspeed_), o_solid){
y+= sign(vspeed_)
}
vspeed_ = 0;
}
x += hspeed_;
y += vspeed_;
ani_start = direction_*ani;
ani_end = ani_start+2;
if image_index>ani_end {
image_index = ani_start;
}
if hspeed_>0 or vspeed_>0{
image_speed = 4;
}
if hspeed_=0 or vspeed_=0{
image_speed = 0;
image_index = 16 + direction_;
}
Code:
/// @description Variables\
keyboard_set_map(ord("W"),vk_up);
keyboard_set_map(ord("A"),vk_left);
keyboard_set_map(ord("S"),vk_down);
keyboard_set_map(ord("D"),vk_right);
hspeed_ = 0;
vspeed_ = 0;
Gravity_ = 2
Accel_ = 2;
maxhspeed_ = 5;
maxvspeed_ = 5;
hmove_ = 0;
vmove_ = 0;
Z = 2
B = 1
direction_ = 0
ani_start = 0;
ani_end = image_number - 1;
ani = 4
The sprite itself has 20 frames (4 walking frames for each cardinal direction [the first 16 frames] and 1 idle frame for each cardinal direction [the last 4 frames])