Locking directions issue
Posted: Sat Oct 10, 2015 6:13 am
I'm having an issue locking movement to 4 directions.
If you hold left arrow then hold right arrow, it will ignore the right arrow. But if you do it the opposite direction it triggers left even if the variable is set to the other direction. Likewise, if you hold up arrow, then you hold down arrow it ignores down. But doing the opposite does the same problem as left/right. I think its a bug or something with gens emulator? Here is the code.
if ((player1.current_anim == ANIM_STANDSIDES) | (player1.current_anim == ANIM_STANDDOWN) | (player1.current_anim == ANIM_STANDUP)) {player1.lockdir = 1; }
if ((value & BUTTON_UP) && player1.lockdir == 1) player1.lockdir = 2;
if ((value & BUTTON_DOWN) && player1.lockdir == 1) player1.lockdir = 3;
if ((value & BUTTON_LEFT) && player1.lockdir == 1) player1.lockdir = 4;
if ((value & BUTTON_RIGHT) && player1.lockdir == 1) player1.lockdir = 5;
if ((value & BUTTON_UP) && player1.y > 5 && tileproperty == TILEPROP_NOTSOLID && player1.lockdir == 2) { player1.y -= 1; SPR_setPosition(&sprites[player1.zorder], player1.x, player1.y); }
if ((value & BUTTON_DOWN) && player1.y < 176 && tileproperty == TILEPROP_NOTSOLID && player1.lockdir == 3) { player1.y += 1; SPR_setPosition(&sprites[player1.zorder], player1.x, player1.y); }
if ((value & BUTTON_LEFT) && passScreen == 1 && tileproperty == TILEPROP_NOTSOLID && player1.lockdir == 4) { player1.x -= 1; SPR_setPosition(&sprites[player1.zorder], player1.x, player1.y); }
if ((value & BUTTON_RIGHT) && passScreen == 1 && tileproperty == TILEPROP_NOTSOLID && player1.lockdir == 5) { player1.
If you hold left arrow then hold right arrow, it will ignore the right arrow. But if you do it the opposite direction it triggers left even if the variable is set to the other direction. Likewise, if you hold up arrow, then you hold down arrow it ignores down. But doing the opposite does the same problem as left/right. I think its a bug or something with gens emulator? Here is the code.
if ((player1.current_anim == ANIM_STANDSIDES) | (player1.current_anim == ANIM_STANDDOWN) | (player1.current_anim == ANIM_STANDUP)) {player1.lockdir = 1; }
if ((value & BUTTON_UP) && player1.lockdir == 1) player1.lockdir = 2;
if ((value & BUTTON_DOWN) && player1.lockdir == 1) player1.lockdir = 3;
if ((value & BUTTON_LEFT) && player1.lockdir == 1) player1.lockdir = 4;
if ((value & BUTTON_RIGHT) && player1.lockdir == 1) player1.lockdir = 5;
if ((value & BUTTON_UP) && player1.y > 5 && tileproperty == TILEPROP_NOTSOLID && player1.lockdir == 2) { player1.y -= 1; SPR_setPosition(&sprites[player1.zorder], player1.x, player1.y); }
if ((value & BUTTON_DOWN) && player1.y < 176 && tileproperty == TILEPROP_NOTSOLID && player1.lockdir == 3) { player1.y += 1; SPR_setPosition(&sprites[player1.zorder], player1.x, player1.y); }
if ((value & BUTTON_LEFT) && passScreen == 1 && tileproperty == TILEPROP_NOTSOLID && player1.lockdir == 4) { player1.x -= 1; SPR_setPosition(&sprites[player1.zorder], player1.x, player1.y); }
if ((value & BUTTON_RIGHT) && passScreen == 1 && tileproperty == TILEPROP_NOTSOLID && player1.lockdir == 5) { player1.