A
AquaticChaos
Guest
I haven't used GMS 2 that much, considering I've just gotten a better laptop to play games and code on (My old computer can't run it), plus I've used GMS 1.4 since 2016. The main issue I'm running into is that, for some odd reason, the Dash state won't return to the Move state after the variable 'dashspd' is less than or equal to 0, which should be continously decreasing. However, neither occurs despite being in the Step event. Here's the entire code.
Code:
/// @description States
scr_Input();
if(event == Move) {
#region Move
//Horizontal
var move = key_right - key_left;
hsp = move*walkspd;
if(place_meeting(x + hsp, y, obj_Wall)) {
while(!place_meeting(x+sign(hsp), y, obj_Wall)) {
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
//Vertical
vsp += grv;
if(place_meeting(x, y + 1, obj_Wall) && key_jump) {
vsp = -10;
}
if(place_meeting(x, y + vsp, obj_Wall)) {
while(!place_meeting(x, y+sign(vsp), obj_Wall)) {
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
//Animation
if(!place_meeting(x, y+1, obj_Wall)) {
//Rise or Fall sprite (0 = Rise, 1 = Fall)
sprite_index = spr_PlayerFall;
image_speed = 0;
if(vsp > 0) {image_index = 1;} else if(vsp < 0) {image_index = 0;}
} else {
image_speed = 1;
//Idle sprite, or...
if(hsp == 0) {sprite_index = spr_PlayerStand;} else {
//Run sprite
sprite_index = spr_PlayerRun;
}
}
if(hsp!= 0) {
image_xscale = sign(hsp);
}
if(key_sword) {event = Attack;}
else if(key_dash) {event = Dash;}
#endregion
}
else if(event == Attack) {
#region Attack
#endregion
}
else if (event == Dash) {
#region Dash
sprite_index = spr_PlayerDash;
dashspd = 2;
if(dashspd <= 0) {event = Move;} else {x += image_xscale*walkspd*dashspd; dashspd -= .05;}
#endregion
}