added new game element "rocket" to native BD game engine
authorHolger Schemel <holger.schemel@virtion.de>
Mon, 7 Oct 2024 21:25:31 +0000 (23:25 +0200)
committerHolger Schemel <holger.schemel@virtion.de>
Mon, 7 Oct 2024 21:25:33 +0000 (23:25 +0200)
src/editor.c
src/game_bd/bd_cave.h
src/game_bd/bd_cavedb.c
src/game_bd/bd_caveengine.c
src/game_bd/bd_elements.h
src/tools.c

index edad7c554234f6a34234a789cffb80636446be46..d5f38ad797c097dfc009af72192f25c89f07ecf1 100644 (file)
@@ -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;
index 420775ba26ce276f137d377aeff89f4ce43f0b6a..cc412d003349263de56ee6dabcca272b8c4fbe9a 100644 (file)
@@ -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
index b633ef12d65214d462ef31f974156e9253f2f404..263809c1b4f72602219cefbcf9baa6c87180c2de 100644 (file)
@@ -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,
index cee8d4e7cceb0003bcccb75a1c61a8fcfecef1c5..f66cce09791630396b8140680eb28203576dd33f 100644 (file)
@@ -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;
 
index 30a087655f2342dad8ed417c798abde2d532399a..032eabba8e1591af15b1be28c4c2e37a647d59e7 100644 (file)
@@ -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,
index b47d06c707f013d31803ca80ee69d5837451aafc..d33e1b1be72e585a9c958aa031571816f33d5a0c 100644 (file)
@@ -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