rogged: move various magic numbers to the settings struct
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ie5cadb3d9dca130b57b858905f549f2d6a6a6964
This commit is contained in:
parent
6050083293
commit
3998fb5259
2 changed files with 16 additions and 5 deletions
10
src/main.c
10
src/main.c
|
|
@ -42,7 +42,7 @@ static void spawn_floating_text(GameState *gs, int x, int y, int value, int is_c
|
|||
gs->floating_texts[slot].x = x;
|
||||
gs->floating_texts[slot].y = y;
|
||||
gs->floating_texts[slot].value = value;
|
||||
gs->floating_texts[slot].lifetime = 60;
|
||||
gs->floating_texts[slot].lifetime = FLOATING_TEXT_LIFETIME;
|
||||
gs->floating_texts[slot].is_critical = is_critical;
|
||||
gs->floating_texts[slot].label[0] = '\0'; // numeric, no label
|
||||
gs->floating_texts[slot].effect_type = EFFECT_NONE;
|
||||
|
|
@ -92,8 +92,8 @@ static void update_effects(GameState *gs) {
|
|||
// update screen shake
|
||||
if (gs->screen_shake > 0) {
|
||||
gs->screen_shake--;
|
||||
gs->shake_x = rng_int(-4, 4);
|
||||
gs->shake_y = rng_int(-4, 4);
|
||||
gs->shake_x = rng_int(-SHAKE_MAX_OFFSET, SHAKE_MAX_OFFSET);
|
||||
gs->shake_y = rng_int(-SHAKE_MAX_OFFSET, SHAKE_MAX_OFFSET);
|
||||
} else {
|
||||
gs->shake_x = 0;
|
||||
gs->shake_y = 0;
|
||||
|
|
@ -139,7 +139,7 @@ static void tick_all_effects(GameState *gs) {
|
|||
int player_effect_dmg = combat_tick_effects(&gs->player);
|
||||
if (player_effect_dmg > 0) {
|
||||
spawn_floating_text(gs, gs->player.x * TILE_SIZE + 8, gs->player.y * TILE_SIZE, player_effect_dmg, 0);
|
||||
gs->screen_shake = 4;
|
||||
gs->screen_shake = SHAKE_EFFECT_DURATION;
|
||||
}
|
||||
|
||||
// Check if player died from effects
|
||||
|
|
@ -222,7 +222,7 @@ static void post_action(GameState *gs, Enemy *attacked_enemy) {
|
|||
// Check if player took damage
|
||||
if (combat_was_player_damage() && combat_get_last_damage() > 0) {
|
||||
audio_play_player_damage(gs);
|
||||
gs->screen_shake = 8;
|
||||
gs->screen_shake = SHAKE_PLAYER_DAMAGE_DURATION;
|
||||
gs->damage_taken += combat_get_last_damage();
|
||||
gs->times_hit++;
|
||||
spawn_floating_text(gs, gs->player.x * TILE_SIZE + 8, gs->player.y * TILE_SIZE, combat_get_last_damage(),
|
||||
|
|
|
|||
|
|
@ -52,4 +52,15 @@
|
|||
#define PLAYER_BASE_DODGE 5
|
||||
#define PLAYER_BASE_BLOCK 0
|
||||
|
||||
// Screen shake
|
||||
#define SHAKE_EFFECT_DURATION 4
|
||||
#define SHAKE_PLAYER_DAMAGE_DURATION 8
|
||||
#define SHAKE_MAX_OFFSET 4
|
||||
|
||||
// Floating text
|
||||
#define FLOATING_TEXT_LIFETIME 60
|
||||
|
||||
// Message timer
|
||||
#define MESSAGE_TIMER_DURATION 60
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue