mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-11-24 09:52:20 -05:00
Fix jumping
This commit is contained in:
parent
7fcbd9d838
commit
26a8f4adab
Binary file not shown.
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 3.1 KiB |
@ -34,7 +34,7 @@
|
||||
/**
|
||||
Initial upwards speed of player's jump, in squares per second.
|
||||
*/
|
||||
#define SFG_PLAYER_JUMP_SPEED 80
|
||||
#define SFG_PLAYER_JUMP_SPEED 5
|
||||
|
||||
/**
|
||||
Melee and close-up attack range, in RCL_Units.
|
||||
@ -261,6 +261,13 @@
|
||||
#define SFG_GRAVITY_SPEED_INCREASE_PER_FRAME 1
|
||||
#endif
|
||||
|
||||
#define SFG_PLAYER_JUMP_OFFSET_PER_FRAME \
|
||||
((SFG_PLAYER_JUMP_SPEED * RCL_UNITS_PER_SQUARE) / SFG_FPS)
|
||||
|
||||
#if SFG_PLAYER_JUMP_OFFSET_PER_FRAME == 0
|
||||
#define SFG_PLAYER_JUMP_OFFSET_PER_FRAME 1
|
||||
#endif
|
||||
|
||||
#define SFG_HEADBOB_FRAME_INCREASE_PER_FRAME \
|
||||
(SFG_HEADBOB_SPEED / SFG_FPS)
|
||||
|
||||
|
24
main.c
24
main.c
@ -280,6 +280,7 @@ struct
|
||||
uint32_t lastFrameTimeMs;
|
||||
uint8_t selectedMenuItem;
|
||||
uint8_t selectedLevel; ///< Level to play selected in the main menu.
|
||||
uint8_t antiSpam; ///< Prevents log message spamming.
|
||||
} SFG_game;
|
||||
|
||||
/**
|
||||
@ -1370,6 +1371,7 @@ void SFG_init()
|
||||
SFG_game.rayConstraints.maxHits = SFG_RAYCASTING_MAX_HITS;
|
||||
SFG_game.rayConstraints.maxSteps = SFG_RAYCASTING_MAX_STEPS;
|
||||
|
||||
SFG_game.antiSpam = 0;
|
||||
|
||||
SFG_LOG("computing average texture colors")
|
||||
|
||||
@ -2763,7 +2765,7 @@ void SFG_gameStepPlaying()
|
||||
) &&
|
||||
(SFG_player.verticalSpeed == 0) &&
|
||||
(SFG_player.previousVerticalSpeed == 0)) ?
|
||||
SFG_PLAYER_JUMP_SPEED :
|
||||
SFG_PLAYER_JUMP_OFFSET_PER_FRAME : // jump
|
||||
(SFG_player.verticalSpeed - SFG_GRAVITY_SPEED_INCREASE_PER_FRAME);
|
||||
#endif
|
||||
|
||||
@ -3021,6 +3023,18 @@ void SFG_gameStepPlaying()
|
||||
SFG_player.squarePosition[0],
|
||||
SFG_player.squarePosition[1]);
|
||||
|
||||
if ( // squeezer check
|
||||
(SFG_ceilingHeightAt(
|
||||
SFG_player.squarePosition[0],SFG_player.squarePosition[1]) -
|
||||
SFG_floorHeightAt(
|
||||
SFG_player.squarePosition[0],SFG_player.squarePosition[1]))
|
||||
<
|
||||
(RCL_CAMERA_COLL_HEIGHT_ABOVE + RCL_CAMERA_COLL_HEIGHT_BELOW))
|
||||
{
|
||||
SFG_LOG("player is squeezed");
|
||||
SFG_player.health = 0;
|
||||
}
|
||||
|
||||
SFG_updateLevel();
|
||||
|
||||
#if SFG_IMMORTAL == 0
|
||||
@ -3944,8 +3958,14 @@ void SFG_mainLoopBody()
|
||||
steps++;
|
||||
}
|
||||
|
||||
if (steps > 1)
|
||||
if ((steps > 1) && (SFG_game.antiSpam == 0))
|
||||
{
|
||||
SFG_LOG("Failed to reach target FPS! Consider setting a lower value.")
|
||||
SFG_game.antiSpam = 30;
|
||||
}
|
||||
|
||||
if (SFG_game.antiSpam > 0)
|
||||
SFG_game.antiSpam--;
|
||||
|
||||
// render noly once
|
||||
SFG_draw();
|
||||
|
Loading…
Reference in New Issue
Block a user