added support for BD player graphic with bomb or rocket turning back
authorHolger Schemel <holger.schemel@virtion.de>
Sat, 11 Jan 2025 19:50:21 +0000 (20:50 +0100)
committerHolger Schemel <holger.schemel@virtion.de>
Sat, 11 Jan 2025 19:58:29 +0000 (20:58 +0100)
This adds an optional animation for one BD engine iteration cycle
between moving player and waiting player, carrying a bomb or a rocket
launcher (using ".turning" action definition for "player is turning
back to the default waiting position after moving in any direction").

src/conf_gfx.c
src/game_bd/bd_cave.c
src/game_bd/bd_cavedb.c
src/game_bd/bd_elements.h
src/game_bd/bd_graphics.c
src/tools.c

index a1f56f9b2937a404c0f403463ccb7ab6dce37880..60f8969e0a85b171a5a040f8141051783f10958e 100644 (file)
@@ -396,11 +396,15 @@ struct ConfigInfo image_config[] =
   { "bdx_player_with_bomb.xpos",                       "8"                             },
   { "bdx_player_with_bomb.ypos",                       "7"                             },
   { "bdx_player_with_bomb.frames",                     "1"                             },
+  { "bdx_player_with_bomb.turning",                    UNDEFINED_FILENAME              },
+  { "bdx_player_with_bomb.turning.clone_from",         "bdx_player_with_bomb"          },
 
   { "bdx_player_with_rocket_launcher",                 "RocksBD.png"                   },
   { "bdx_player_with_rocket_launcher.xpos",            "10"                            },
   { "bdx_player_with_rocket_launcher.ypos",            "7"                             },
   { "bdx_player_with_rocket_launcher.frames",          "1"                             },
+  { "bdx_player_with_rocket_launcher.turning",         UNDEFINED_FILENAME              },
+  { "bdx_player_with_rocket_launcher.turning.clone_from", "bdx_player_with_rocket_launcher" },
 
   { "bdx_player_stirring",                             "RocksBD.png"                   },
   { "bdx_player_stirring.xpos",                                "8"                             },
index 2f7a9d805f94c090e7a2b783c707a3e7b5570218..6fec4dd6ac168f4e94880253ea585c641ce723e7 100644 (file)
@@ -1620,6 +1620,16 @@ void gd_drawcave_game(const GdCave *cave,
     elemmapping[O_PLAYER_ROCKET_LAUNCHER] = map;
     elemdrawing[O_PLAYER_ROCKET_LAUNCHER] = draw;
   }
+  else if (cave->last_direction_2nd != GD_MV_STILL)
+  {
+    // player with bomb/rocketlauncher which just stopped moving may have separate graphics
+
+    elemmapping[O_PLAYER_BOMB] = O_PLAYER_BOMB_TURNING;
+    elemdrawing[O_PLAYER_BOMB] = gd_element_properties[O_PLAYER_BOMB_TURNING].image_game;
+
+    elemmapping[O_PLAYER_ROCKET_LAUNCHER] = O_PLAYER_ROCKET_LAUNCHER_TURNING;
+    elemdrawing[O_PLAYER_ROCKET_LAUNCHER] = gd_element_properties[O_PLAYER_ROCKET_LAUNCHER_TURNING].image_game;
+  }
 
   elemmapping[O_INBOX] = (cave->inbox_flash_toggle ?
                           O_INBOX_OPEN :
index 8ee0eddfafb8c585021b1783ae24f00c78e0bacb..7adf35f6421e04772c3941ffe6fa050b62613d20 100644 (file)
@@ -1969,6 +1969,16 @@ GdElementProperty gd_element_properties[] =
     P_PLAYER | P_PLAYER_PUSHING,
     NULL, 0, 400, -400, -400
   },
+  {
+    O_PLAYER_BOMB_TURNING, O_PLAYER_BOMB_TURNING, N_("Player with bomb (turning)"),
+    P_PLAYER,
+    NULL, 0, 42, 42, 42,
+  },
+  {
+    O_PLAYER_ROCKET_LAUNCHER_TURNING, O_PLAYER_ROCKET_LAUNCHER_TURNING, N_("Player with rocket launcher (turning)"),
+    P_PLAYER,
+    NULL, 0, 369, 369, 369,
+  },
   {
     O_CREATURE_SWITCH_ON, O_CREATURE_SWITCH_ON, NULL,
     0,
index 13cb0a4a76e68b6d8ce460244381b4a94a2ef3f5..e6dee3b24e04188609c334ec2c9a93c7b7f543df 100644 (file)
@@ -414,6 +414,8 @@ typedef enum _element
   O_PLAYER_TAP_BLINK,
   O_PLAYER_PUSH_LEFT,
   O_PLAYER_PUSH_RIGHT,
+  O_PLAYER_BOMB_TURNING,
+  O_PLAYER_ROCKET_LAUNCHER_TURNING,
   O_CREATURE_SWITCH_ON,
   O_EXPANDING_WALL_SWITCH_HORIZ,
   O_EXPANDING_WALL_SWITCH_VERT,
index 342ee986b3175e70dd2d0ac3851650c05ddad44e..bb45331e207656cee89bf839e6b0cb09af53aeff 100644 (file)
@@ -849,6 +849,11 @@ static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d
   if (!is_moving || !use_smooth_movements)
   {
     struct GraphicInfo_BD *g = &graphic_info_bd_object[draw][frame];
+    int itercycle_capped = MIN(game->itercycle * 8 / game->itermax, 7);
+
+    if (draw == O_PLAYER_BOMB_TURNING ||
+        draw == O_PLAYER_ROCKET_LAUNCHER_TURNING)
+      g = &graphic_info_bd_object[draw][itercycle_capped];
 
     if (el_is_crumbled(draw))
       gd_drawcave_crumbled(dest, game, x, y, draw_masked);
index abefd61c38a29ebf0ca132229a008270036eb1ea..771923dfab825741d67b6d0d95a92d4213169e40 100644 (file)
@@ -8007,6 +8007,14 @@ bd_object_mapping_list[] =
     O_PLAYER_PUSH_RIGHT,                       FALSE,
     EL_BDX_PLAYER,                             ACTION_PUSHING, MV_BIT_RIGHT
   },
+  {
+    O_PLAYER_BOMB_TURNING,                     FALSE,
+    EL_BDX_PLAYER_WITH_BOMB,                   ACTION_TURNING, -1
+  },
+  {
+    O_PLAYER_ROCKET_LAUNCHER_TURNING,          FALSE,
+    EL_BDX_PLAYER_WITH_ROCKET_LAUNCHER,                ACTION_TURNING, -1
+  },
   {
     O_CREATURE_SWITCH_ON,                      FALSE,
     EL_BDX_CREATURE_SWITCH_ACTIVE,             -1, -1
@@ -11365,7 +11373,9 @@ void InitGraphicInfo_BD(void)
                        e == O_DIRT2_DIGGING_LEFT_CRUMBLED  ||
                        e == O_DIRT2_DIGGING_RIGHT_CRUMBLED ||
                        e == O_DIRT2_DIGGING_UP_CRUMBLED    ||
-                       e == O_DIRT2_DIGGING_DOWN_CRUMBLED ? j :
+                       e == O_DIRT2_DIGGING_DOWN_CRUMBLED  ||
+                       e == O_PLAYER_BOMB_TURNING          ||
+                       e == O_PLAYER_ROCKET_LAUNCHER_TURNING ? j :
                        j * 2);
       int frame = getAnimationFrame(g->anim_frames,
                                    g->anim_delay,