added support for diagonal player movement in BD engine to level editor
authorHolger Schemel <info@artsoft.org>
Wed, 28 Feb 2024 21:59:36 +0000 (22:59 +0100)
committerHolger Schemel <info@artsoft.org>
Wed, 28 Feb 2024 21:59:43 +0000 (22:59 +0100)
src/editor.c
src/files.c
src/main.h

index ac2bb22020495f36f4cd2d40783eaf2e3ee05867..5a5dc93d6e207b8d177dafd55d9b32ba6920ae4d 100644 (file)
@@ -679,6 +679,7 @@ enum
   GADGET_ID_CAN_FALL_INTO_ACID,
   GADGET_ID_CAN_MOVE_INTO_ACID,
   GADGET_ID_DONT_COLLIDE_WITH,
+  GADGET_ID_BD_DIAGONAL_MOVEMENTS,
   GADGET_ID_ENVELOPE_AUTOWRAP,
   GADGET_ID_ENVELOPE_CENTERED,
   GADGET_ID_MM_LASER_RED,
@@ -994,6 +995,7 @@ enum
   ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID,
   ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID,
   ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH,
+  ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS,
   ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP,
   ED_CHECKBUTTON_ID_ENVELOPE_CENTERED,
   ED_CHECKBUTTON_ID_MM_LASER_RED,
@@ -3328,6 +3330,13 @@ static struct
     NULL, NULL,
     "deadly when colliding with",      "element is deadly when hitting player"
   },
+  {
+    ED_ELEMENT_SETTINGS_XPOS(0),       ED_ELEMENT_SETTINGS_YPOS(0),
+    GADGET_ID_BD_DIAGONAL_MOVEMENTS,   GADGET_ID_NONE,
+    &level.bd_diagonal_movements,
+    NULL, NULL,
+    "can move diagonally",             "player can move diagonally"
+  },
   {
     ED_ELEMENT_SETTINGS_XPOS(0),       ED_ELEMENT_SETTINGS_YPOS(1),
     GADGET_ID_ENVELOPE_AUTOWRAP,       GADGET_ID_NONE,
@@ -10331,6 +10340,7 @@ static boolean checkPropertiesConfig(int element)
       CAN_GROW(element) ||
       COULD_MOVE_INTO_ACID(element) ||
       MAYBE_DONT_COLLIDE_WITH(element) ||
+      element == EL_BD_PLAYER ||
       element == EL_SOKOBAN_OBJECT ||
       element == EL_SOKOBAN_FIELD_EMPTY ||
       element == EL_SOKOBAN_FIELD_FULL)
@@ -10565,6 +10575,9 @@ static void DrawPropertiesConfig(void)
     }
   }
 
+  if (properties_element == EL_BD_PLAYER)
+    MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_DIAGONAL_MOVEMENTS);
+
   if (IS_GEM(properties_element))
     MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
 
index 433f68134896aac251a6ea338c3f831509e7dc5c..b48fcf4a1482b38942301fbadb8396be182513f0 100644 (file)
@@ -563,6 +563,15 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] =
     &li.initial_inventory_size[3],     1, MAX_INITIAL_INVENTORY_SIZE
   },
 
+  // (these values are only valid for BD style levels)
+  {
+    EL_BD_PLAYER,                      -1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(1),
+    &li.bd_diagonal_movements,         FALSE
+  },
+
+  // (the following values are related to various game elements)
+
   {
     EL_EMERALD,                                -1,
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
@@ -3710,6 +3719,8 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level)
 
   cave->level_speed[0]                 = 160;  // set cave speed
 
+  cave->diagonal_movements             = level->bd_diagonal_movements;
+
   strncpy(cave->name, level->name, sizeof(GdString));
   cave->name[sizeof(GdString) - 1] = '\0';
 
@@ -3735,6 +3746,8 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level)
   level->score[SC_TIME_BONUS]  = cave->level_timevalue[bd_level_nr];
   level->score[SC_DIAMOND]     = cave->diamond_value;
 
+  level->bd_diagonal_movements = cave->diagonal_movements;
+
   strncpy(level->name, cave->name, MAX_LEVEL_NAME_LEN);
   level->name[MAX_LEVEL_NAME_LEN] = '\0';
 
index 1ed645e206ae8b9883d7eaede991823e89af04c3..68b2cd695d0b50fc80a4d3f89f2405fd1435ce69 100644 (file)
@@ -3466,6 +3466,7 @@ struct LevelInfo
   int initial_inventory_size[MAX_PLAYERS];
   int initial_inventory_content[MAX_PLAYERS][MAX_INITIAL_INVENTORY_SIZE];
 
+  boolean bd_diagonal_movements;       // BD style diagonal movements
   boolean em_slippery_gems;            // EM style "gems slip from wall" behaviour
   boolean em_explodes_by_fire;         // EM style chain explosion behaviour
   boolean use_spring_bug;              // for compatibility with old levels