From ff853c5fe8ee75a8795b90d5e416e1db8e8eb6c1 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 16 Dec 2024 19:40:44 +0100 Subject: [PATCH] fixed smoothing player movement with variable cave speed in BD engine --- src/game_bd/bd_gameplay.c | 13 ++++--------- src/game_bd/bd_gameplay.h | 2 -- src/game_bd/main_bd.c | 2 -- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/game_bd/bd_gameplay.c b/src/game_bd/bd_gameplay.c index 260d6d4a..d134f0e8 100644 --- a/src/game_bd/bd_gameplay.c +++ b/src/game_bd/bd_gameplay.c @@ -150,8 +150,6 @@ static void load_cave(GdGame *game) game->milliseconds_anim = 0; game->milliseconds_game = 0; // set game timer to zero, too - game->cycle_counter = 0; - // create new element buffer game->element_buffer = gd_cave_map_new(game->cave, int); @@ -462,19 +460,16 @@ static GdGameState gd_game_main_int(GdGame *game, boolean allow_iterate, boolean // store last maximum number of cycle frames (to force redraw if changed) game->itermax_last = game->itermax; - // store maximum number of cycle frames separately for even and odd cycles - game->itermax2[game->cycle_counter % 2] = game->itercycle; - - // update maximum number of cycle frames per cave iteration - game->itermax = game->itermax2[!(game->cycle_counter % 2)]; + // calculate expected maximum number of cycle frames for next cave iteration + // (assuming constant cave speed, which in fact might not always be the case) + game->itermax = + (cavespeed - game->milliseconds_game + millisecs_elapsed - 1) / millisecs_elapsed; // reset cycle frame counter for the next cave iteration game->itercycle = 0; iterate_cave(game, game->player_move, game->player_fire, game->player_suicide); - game->cycle_counter++; - if (game->player_move == GD_MV_STILL) { game->player_move_stick = FALSE; diff --git a/src/game_bd/bd_gameplay.h b/src/game_bd/bd_gameplay.h index adbb37a3..fdacddef 100644 --- a/src/game_bd/bd_gameplay.h +++ b/src/game_bd/bd_gameplay.h @@ -89,11 +89,9 @@ typedef struct _gd_game int itercycle; int itermax; int itermax_last; - int itermax2[2]; int animcycle; int milliseconds_game; int milliseconds_anim; - int cycle_counter; int replay_no_more_movements; boolean show_story; // to remember that story for a particular cave was already shown. diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index 488837b8..a94dfde2 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -334,8 +334,6 @@ void InitGameEngine_BD(void) game_bd.game->itercycle = 0; game_bd.game->itermax = 8; // default; dynamically changed at runtime game_bd.game->itermax_last = game_bd.game->itermax; - game_bd.game->itermax2[0] = game_bd.game->itermax; - game_bd.game->itermax2[1] = game_bd.game->itermax; game_bd.game->use_old_engine = useOldEngine_BD(); -- 2.34.1