From 1f233d78948c3669c7a698d9f3813816198a375f Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 5 Oct 2024 19:11:41 +0200 Subject: [PATCH] added support for moving/pushing rock animations to BD engine --- src/game_bd/bd_cave.c | 21 ++++++++++++++++++++- src/game_bd/bd_cave.h | 2 +- src/game_bd/bd_cavedb.c | 21 +++++++++++++++++++++ src/game_bd/bd_elements.h | 5 +++++ src/game_bd/bd_gameplay.c | 2 +- src/tools.c | 16 ++++++++++++++++ 6 files changed, 64 insertions(+), 3 deletions(-) diff --git a/src/game_bd/bd_cave.c b/src/game_bd/bd_cave.c index f85088fd..7a579b43 100644 --- a/src/game_bd/bd_cave.c +++ b/src/game_bd/bd_cave.c @@ -1379,7 +1379,7 @@ static inline boolean el_pushable(const int element) void gd_drawcave_game(const GdCave *cave, int **element_buffer, int **last_element_buffer, int **drawing_buffer, int **last_drawing_buffer, int **gfx_buffer, - int **covered_buffer, + int **covered_buffer, int **dir_buffer_from, int **dir_buffer_to, boolean bonus_life_flash, int animcycle, boolean hate_invisible_outbox) { static boolean player_blinking = FALSE; @@ -1630,6 +1630,7 @@ void gd_drawcave_game(const GdCave *cave, for (x = cave->x1; x <= cave->x2; x++) { GdElement actual = cave->map[y][x]; + int dir_to = dir_buffer_to[y][x]; // if covered, real element is not important if (covered_buffer[y][x]) @@ -1643,6 +1644,24 @@ void gd_drawcave_game(const GdCave *cave, draw = elemdrawing[actual]; } + // draw special graphics if element is moving + if (dir_to == GD_MV_LEFT || dir_to == GD_MV_RIGHT) + { + if (actual == O_STONE || actual == O_STONE_F) + { + if (dir_to == GD_MV_LEFT) + { + map = O_STONE_MOVE_LEFT; + draw = elemdrawing[O_STONE_MOVE_LEFT]; + } + else + { + map = O_STONE_MOVE_RIGHT; + draw = elemdrawing[O_STONE_MOVE_RIGHT]; + } + } + } + // draw special graphics if player is pushing something (but not while stirring the pot) if (use_bd_pushing_graphics() && (cave->last_direction == GD_MV_LEFT || cave->last_direction == GD_MV_RIGHT) && diff --git a/src/game_bd/bd_cave.h b/src/game_bd/bd_cave.h index 0c7300e7..420775ba 100644 --- a/src/game_bd/bd_cave.h +++ b/src/game_bd/bd_cave.h @@ -728,7 +728,7 @@ GdScheduling gd_scheduling_from_string(const char *str); void gd_drawcave_game(const GdCave *cave, int **element_buffer, int **last_element_buffer, int **drawing_buffer, int **last_drawing_buffer, int **gfx_buffer, - int **covered_buffer, + int **covered_buffer, int **dir_buffer_from, int **dir_buffer_to, boolean bonus_life_flash, int animcycle, boolean hate_invisible_outbox); // function to copy a GdString diff --git a/src/game_bd/bd_cavedb.c b/src/game_bd/bd_cavedb.c index 1e30fbb5..4290398b 100644 --- a/src/game_bd/bd_cavedb.c +++ b/src/game_bd/bd_cavedb.c @@ -1891,6 +1891,27 @@ GdElementProperty gd_element_properties[] = NULL, 0, 15, 15, 15 }, + { + O_STONE_MOVE_LEFT, O_STONE_MOVE_LEFT, N_("Stone, moved left"), + 0, + NULL, 0, 1, 1, 1, + }, + { + O_STONE_MOVE_RIGHT, O_STONE_MOVE_RIGHT, N_("Stone, moved right"), + 0, + NULL, 0, 1, 1, 1, + }, + { + O_STONE_PUSH_LEFT, O_STONE_PUSH_LEFT, N_("Stone, pushed left"), + 0, + NULL, 0, 1, 1, 1, + }, + { + O_STONE_PUSH_RIGHT, O_STONE_PUSH_RIGHT, N_("Stone, pushed right"), + 0, + NULL, 0, 1, 1, 1, + }, + { O_QUESTION_MARK, O_QUESTION_MARK, NULL, 0, diff --git a/src/game_bd/bd_elements.h b/src/game_bd/bd_elements.h index ad594c46..30a08765 100644 --- a/src/game_bd/bd_elements.h +++ b/src/game_bd/bd_elements.h @@ -400,6 +400,11 @@ typedef enum _element O_BITER_SWITCH_3, O_BITER_SWITCH_4, + O_STONE_MOVE_LEFT, + O_STONE_MOVE_RIGHT, + O_STONE_PUSH_LEFT, + O_STONE_PUSH_RIGHT, + O_QUESTION_MARK, O_EATABLE, O_DOWN_ARROW, diff --git a/src/game_bd/bd_gameplay.c b/src/game_bd/bd_gameplay.c index 629e0362..eef5ddae 100644 --- a/src/game_bd/bd_gameplay.c +++ b/src/game_bd/bd_gameplay.c @@ -644,7 +644,7 @@ static GdGameState gd_game_main_int(GdGame *game, boolean allow_iterate, boolean if (game->element_buffer && game->drawing_buffer && game->gfx_buffer) gd_drawcave_game(game->cave, game->element_buffer, game->last_element_buffer, game->drawing_buffer, game->last_drawing_buffer, game->gfx_buffer, - game->covered_buffer, + game->covered_buffer, game->dir_buffer_from, game->dir_buffer_to, game->bonus_life_flash != 0, game->animcycle, setup.bd_show_invisible_outbox); game->state_counter = counter_next; diff --git a/src/tools.c b/src/tools.c index 460bf148..2b40ad41 100644 --- a/src/tools.c +++ b/src/tools.c @@ -7892,6 +7892,22 @@ bd_object_mapping_list[] = O_BITER_SWITCH_4, FALSE, EL_BDX_BITER_SWITCH_4, -1, -1 }, + { + O_STONE_MOVE_LEFT, FALSE, + EL_BDX_ROCK, ACTION_MOVING, MV_BIT_LEFT + }, + { + O_STONE_MOVE_RIGHT, FALSE, + EL_BDX_ROCK, ACTION_MOVING, MV_BIT_RIGHT + }, + { + O_STONE_PUSH_LEFT, FALSE, + EL_BDX_ROCK, ACTION_PUSHING, MV_BIT_LEFT + }, + { + O_STONE_PUSH_RIGHT, FALSE, + EL_BDX_ROCK, ACTION_PUSHING, MV_BIT_RIGHT + }, { -1, FALSE, -- 2.34.1