M
Matheus
Guest
Well, i coded states of my player, for now, i have 5 states:
free: the player will have no sword, and able do move
attack: the player will attack, showing the attack animation (no coded yet)
saque: the player will withdraw the sword and no move, showing the withdraw sword animation
combatemode: the player will have the sword in hand and able do move
guarda: the player will retain the sword and no move, showing the retain sword animation
the logic is FREE -> SAQUE -> COMBATEMODE(able to ATTACK) -> GUARDA -> FREE;
and the logic is going well, no failure. But sometimes the retain ou withdraw sword animation just are speedup, skipping some frames, and sometimes is going right in normal speed and no skipping frame. I want that every time the player retain or withdraw the sword is going in normal speed and no skipping frames.
below, my code
free: the player will have no sword, and able do move
attack: the player will attack, showing the attack animation (no coded yet)
saque: the player will withdraw the sword and no move, showing the withdraw sword animation
combatemode: the player will have the sword in hand and able do move
guarda: the player will retain the sword and no move, showing the retain sword animation
the logic is FREE -> SAQUE -> COMBATEMODE(able to ATTACK) -> GUARDA -> FREE;
and the logic is going well, no failure. But sometimes the retain ou withdraw sword animation just are speedup, skipping some frames, and sometimes is going right in normal speed and no skipping frame. I want that every time the player retain or withdraw the sword is going in normal speed and no skipping frames.
below, my code
GML:
scr_input();
scr_dano();
switch(state){
case PlayerState.free:
#region free
if(step = 0){
count = 8;
}
count3 ++;
scr_moveverifc();
if(space == 1 and count3 > 20){ //TRANSIÇÃO
state = PlayerState.saque;
count3 = 0;
}else if(rkey == 1 and ukey == 1){ //Up Right
sprite_index = spr_PlayerDiagCA;
image_xscale = 1;
frente = false;
count = 0;
count2 = 0;
}
else if(lkey == 1 and ukey == 1){ //UP Left
sprite_index = spr_PlayerDiagCA;
image_xscale = -1;
frente = false;
count = 0;
count2 = 0;
}
else if(rkey == 1 and dkey == 1){ //Down Right
sprite_index = spr_PlayerDiagFA;
image_xscale = 1;
frente = true;
count = 0;
count2 = 0;
}
else if(lkey == 1 and dkey == 1){ //Down Left
sprite_index = spr_PlayerDiagFAI;
image_xscale = -1;
frente = true;
count = 0;
count2 = 0;
}
else if(rkey == 1){ //Right
sprite_index = spr_PlayerFrenteA;
image_xscale = 1;
count += 1;
count2 += 1;
}
else if(lkey == 1){ //Left
sprite_index = spr_PlayerFrenteAI;
image_xscale = -1;
count += 1;
count2 += 1;
}
else if(ukey == 1){ //Up
sprite_index = spr_PlayerdicostaA;
frente = false;
count += 1;
count2 = 0;
}
else if(dkey == 1){ //Down
sprite_index = spr_PlayerFrenteA;
frente = true;
count += 1;
count2 = 0;
}
else{
if(count < 7 and frente == true){
if(image_xscale == 1){sprite_index = spr_PlayerDiagFP;}
else{sprite_index = spr_PlayerDiagFPI;}
}
else if(count < 7 and frente == false){
sprite_index = spr_playerDiagCP;
}
else if(frente == true or count2 > 1){
if(frente == false){
sprite_index = spr_PlayerdicostaP;
}
if(image_xscale == 1){sprite_index = spr_PlayerFrenteP;}
else{sprite_index = spr_PlayerFrentePI;}
}
else{
sprite_index = spr_PlayerdicostaP;
}
}
if(step < 2){
step += 1;
}
#endregion
break;
case PlayerState.saque:
#region saque
sprite_index = spr_PlayerSaque;
if(sprite_index == spr_PlayerSaque and image_index > 4){
show_debug_message("SAQUE")
state = PlayerState.combatemode;
}
#endregion
break;
case PlayerState.combatemode:
#region combatmode
scr_moveverifc();
count3 ++;
if(space == 1 and count3 > 20){ //TRANSICAO
count3 = 0;
state = PlayerState.guarda;
}else if(rkey == 1){
sprite_index = spr_PlayerMovCombat;
image_xscale = 1;
}else if(lkey == 1){
sprite_index = spr_PlayerMovCombat;
image_xscale = -1;
}else{
sprite_index = spr_PlayerIdleCombat;
}
#endregion
break;
case PlayerState.guarda:
#region guarda
sprite_index = spr_PlayerGuarda;
if(sprite_index == spr_PlayerGuarda and image_index > 4){
show_debug_message("GUARDA")
state = PlayerState.free;
}
#endregion
break;
}