Fix a speed bug

This commit is contained in:
Miloslav Číž 2020-11-30 21:06:52 +01:00
parent 535db88b6e
commit 6a388227fe
3 changed files with 21 additions and 8 deletions

View File

@ -126,13 +126,9 @@ level ideas:
over a hole, leading to an easter egg over a hole, leading to an easter egg
- start of level: a corner blocked by an invisible wall, to indicate entrance DONE - start of level: a corner blocked by an invisible wall, to indicate entrance DONE
- small pyramid from diffetently elevated floor tiles - small pyramid from diffetently elevated floor tiles
- add time slowdown constant
bugs: bugs:
- On Pokitto/GB Meta sometimes after turn on the game starts midway loading the
first level.
done: done:
- add headbob - add headbob
@ -221,6 +217,10 @@ done:
- Add FOV options. RCL doesn't project sprites with different FOV correctly - - Add FOV options. RCL doesn't project sprites with different FOV correctly -
FIX! FIX!
- When selecting continue from menu, the player shoots - fix! - When selecting continue from menu, the player shoots - fix!
- FIX: running diagonally (forward + strafe) player can jump over 3 squares!
- add time slowdown constant
- On Pokitto/GB Meta sometimes after turn on the game starts midway loading the
first level.
scratched: scratched:
- option for disabling wall transparency, for performance? - option for disabling wall transparency, for performance?

15
game.h
View File

@ -3237,8 +3237,23 @@ void SFG_gameStepPlaying()
if (strafe != 0) if (strafe != 0)
{ {
uint8_t normalize = (moveOffset.x != 0) || (moveOffset.y != 0);
moveOffset.x += strafe * SFG_player.direction.y; moveOffset.x += strafe * SFG_player.direction.y;
moveOffset.y -= strafe * SFG_player.direction.x; moveOffset.y -= strafe * SFG_player.direction.x;
if (normalize)
{
// This prevents reaching higher speed when moving diagonally.
moveOffset = RCL_normalize(moveOffset);
moveOffset.x = (moveOffset.x * SFG_PLAYER_MOVE_UNITS_PER_FRAME)
/ RCL_UNITS_PER_SQUARE;
moveOffset.y = (moveOffset.y * SFG_PLAYER_MOVE_UNITS_PER_FRAME)
/ RCL_UNITS_PER_SQUARE;
}
} }
#if SFG_PREVIEW_MODE #if SFG_PREVIEW_MODE

View File

@ -106,8 +106,6 @@ int8_t SFG_keyPressed(uint8_t key)
case SFG_KEY_DOWN: return joy.JoyX() > axisThreshold2; break; case SFG_KEY_DOWN: return joy.JoyX() > axisThreshold2; break;
case SFG_KEY_RIGHT: return joy.JoyY() > axisThreshold2; break; case SFG_KEY_RIGHT: return joy.JoyY() > axisThreshold2; break;
case SFG_KEY_LEFT: return joy.JoyY() < axisThreshold1; break; case SFG_KEY_LEFT: return joy.JoyY() < axisThreshold1; break;
case SFG_KEY_A: return pokitto.bBtn(); break;
case SFG_KEY_B: return pokitto.aBtn(); break;
case SFG_KEY_JUMP: return pokitto.rightBtn(); break; case SFG_KEY_JUMP: return pokitto.rightBtn(); break;
case SFG_KEY_STRAFE_RIGHT: return pokitto.downBtn(); break; case SFG_KEY_STRAFE_RIGHT: return pokitto.downBtn(); break;
case SFG_KEY_STRAFE_LEFT: return pokitto.upBtn(); break; case SFG_KEY_STRAFE_LEFT: return pokitto.upBtn(); break;
@ -119,10 +117,10 @@ int8_t SFG_keyPressed(uint8_t key)
case SFG_KEY_DOWN: return pokitto.downBtn(); break; case SFG_KEY_DOWN: return pokitto.downBtn(); break;
case SFG_KEY_RIGHT: return pokitto.rightBtn(); break; case SFG_KEY_RIGHT: return pokitto.rightBtn(); break;
case SFG_KEY_LEFT: return pokitto.leftBtn(); break; case SFG_KEY_LEFT: return pokitto.leftBtn(); break;
case SFG_KEY_A: return pokitto.aBtn(); break;
case SFG_KEY_B: return pokitto.bBtn(); break;
#endif #endif
case SFG_KEY_A: return pokitto.aBtn(); break;
case SFG_KEY_B: return pokitto.bBtn(); break;
case SFG_KEY_C: return pokitto.cBtn(); break; case SFG_KEY_C: return pokitto.cBtn(); break;
default: return 0; break; default: return 0; break;
} }