From 5d537d68acf6b5a435423d32c5ebab763f1627b5 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 7 Oct 2024 23:25:31 +0200 Subject: [PATCH] added new game element "rocket" to native BD game engine --- src/editor.c | 5 +++++ src/game_bd/bd_cave.h | 1 + src/game_bd/bd_cavedb.c | 5 +++++ src/game_bd/bd_caveengine.c | 20 ++++++++++++++++---- src/game_bd/bd_elements.h | 1 + src/tools.c | 4 ++++ 6 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/editor.c b/src/editor.c index edad7c55..d5f38ad7 100644 --- a/src/editor.c +++ b/src/editor.c @@ -5793,6 +5793,11 @@ static int editor_el_boulderdash_native[] = EL_BDX_GRAVITY_SWITCH, EL_BDX_PNEUMATIC_HAMMER, EL_BDX_TELEPORTER, + + EL_BDX_ROCKET, + EL_EMPTY, + EL_EMPTY, + EL_EMPTY, }; static int *editor_hl_boulderdash_native_ptr = editor_hl_boulderdash_native; static int *editor_el_boulderdash_native_ptr = editor_el_boulderdash_native; diff --git a/src/game_bd/bd_cave.h b/src/game_bd/bd_cave.h index 420775ba..cc412d00 100644 --- a/src/game_bd/bd_cave.h +++ b/src/game_bd/bd_cave.h @@ -606,6 +606,7 @@ typedef struct _gd_cave int diamonds_needed; // diamonds needed to open outbox int diamonds_collected; // diamonds collected int skeletons_collected; // number of skeletons collected + int rockets_collected; // number of rockets collected int gate_open_flash; // flashing of screen when gate opens int score; // Score got this frame. int amoeba_time; // Amoeba growing slow (low probability, default 3%) for diff --git a/src/game_bd/bd_cavedb.c b/src/game_bd/bd_cavedb.c index b633ef12..263809c1 100644 --- a/src/game_bd/bd_cavedb.c +++ b/src/game_bd/bd_cavedb.c @@ -1309,6 +1309,11 @@ GdElementProperty gd_element_properties[] = 0, "ROCKET_LAUNCHER", 0, 368, 368, 368 }, + { + O_ROCKET, O_ROCKET, N_("Rocket"), + 0, + "ROCKET", 0, 365, 365, 365 + }, { O_ROCKET_1, O_ROCKET_1_scanned, N_("Rocket (right)"), P_CAN_MOVE, diff --git a/src/game_bd/bd_caveengine.c b/src/game_bd/bd_caveengine.c index cee8d4e7..f66cce09 100644 --- a/src/game_bd/bd_caveengine.c +++ b/src/game_bd/bd_caveengine.c @@ -1159,6 +1159,10 @@ static GdElement player_eat_element(GdCave *cave, const GdElement element, int x gd_sound_play(cave, GD_S_SKELETON_COLLECTING, element, x, y); return O_SPACE; + case O_ROCKET: + cave->rockets_collected++; + return O_SPACE; + case O_OUTBOX: case O_INVIS_OUTBOX: cave->player_state = GD_PL_EXITED; // player now exits the cave! @@ -2166,25 +2170,33 @@ void gd_cave_iterate(GdCave *cave, GdDirection player_move, boolean player_fire, { case GD_MV_RIGHT: store_dir(cave, x, y, player_move, O_ROCKET_1); - if (!cave->infinite_rockets) + if (cave->rockets_collected > 0) + cave->rockets_collected--; + else if (!cave->infinite_rockets) store(cave, x, y, O_PLAYER); break; case GD_MV_UP: store_dir(cave, x, y, player_move, O_ROCKET_2); - if (!cave->infinite_rockets) + if (cave->rockets_collected > 0) + cave->rockets_collected--; + else if (!cave->infinite_rockets) store(cave, x, y, O_PLAYER); break; case GD_MV_LEFT: store_dir(cave, x, y, player_move, O_ROCKET_3); - if (!cave->infinite_rockets) + if (cave->rockets_collected > 0) + cave->rockets_collected--; + else if (!cave->infinite_rockets) store(cave, x, y, O_PLAYER); break; case GD_MV_DOWN: store_dir(cave, x, y, player_move, O_ROCKET_4); - if (!cave->infinite_rockets) + if (cave->rockets_collected > 0) + cave->rockets_collected--; + else if (!cave->infinite_rockets) store(cave, x, y, O_PLAYER); break; diff --git a/src/game_bd/bd_elements.h b/src/game_bd/bd_elements.h index 30a08765..032eabba 100644 --- a/src/game_bd/bd_elements.h +++ b/src/game_bd/bd_elements.h @@ -272,6 +272,7 @@ typedef enum _element O_PLAYER_STIRRING, O_ROCKET_LAUNCHER, + O_ROCKET, O_ROCKET_1, O_ROCKET_1_scanned, O_ROCKET_2, diff --git a/src/tools.c b/src/tools.c index b47d06c7..d33e1b1b 100644 --- a/src/tools.c +++ b/src/tools.c @@ -6974,6 +6974,10 @@ bd_object_mapping_list[] = O_ROCKET_LAUNCHER, TRUE, EL_BDX_ROCKET_LAUNCHER, -1, -1 }, + { + O_ROCKET, TRUE, + EL_BDX_ROCKET, -1, -1 + }, { O_ROCKET_1, TRUE, EL_BDX_ROCKET_RIGHT, -1, -1 -- 2.34.1