rnd-20060128-1-src
[rocksndiamonds.git] / src / game.c
index e1cd4686b61546bee5012001111e375367633ae0..2ac9f0d03941d55f96b0091efe3c70dfe8aea41e 100644 (file)
@@ -333,7 +333,7 @@ static void RunTimegateWheel(int, int);
 static void InitMagicBallDelay(int, int);
 static void ActivateMagicBall(int, int);
 
-static void InitAndroid(int, int);
+static void InitDiagonalMovingElement(int, int);
 
 struct ChangingElementInfo
 {
@@ -517,20 +517,20 @@ static struct ChangingElementInfo change_delay_list[] =
     NULL
   },
   {
-    EL_EMC_ANDROID_SHRINKING,
+    EL_DIAGONAL_SHRINKING,
     EL_EMPTY,
-    8,
+    0,
     NULL,
     NULL,
     NULL
   },
   {
-    EL_EMC_ANDROID_GROWING,
-    EL_EMC_ANDROID,
-    8,
+    EL_DIAGONAL_GROWING,
+    EL_EMPTY,
+    0,
     NULL,
     NULL,
-    InitAndroid
+    InitDiagonalMovingElement
   },
 
   {
@@ -4905,14 +4905,15 @@ inline static void TurnRoundExt(int x, int y)
       int start_pos = check_pos[MovDir[x][y] & 0x0f];
       int i;
 
-      MovDelay[x][y] = level.android_move_time;
+      MovDelay[x][y] = level.android_move_time * 8 + 1;
 
       if (start_pos < 0)       /* (should never happen) */
        return;
 
       for (i = 0; i < 3; i++)
       {
-       int pos_raw = start_pos + (i == 0 ? 0 : i == 1 ? 1 : -1) * check_order;
+       /* first check start_pos, then previous/next or (next/previous) pos */
+       int pos_raw = start_pos + (i < 2 ? i : -1) * check_order;
        int pos = (pos_raw + 8) % 8;
        int newx = x + check_xy[pos].dx;
        int newy = y + check_xy[pos].dy;
@@ -5177,7 +5178,7 @@ static void TurnRound(int x, int y)
     GfxFrame[x][y] = 0;
 
   if (MovDelay[x][y])
-    GfxAction[x][y] = ACTION_TURNING_FROM_LEFT + MV_DIR_BIT(direction);
+    GfxAction[x][y] = ACTION_TURNING_FROM_LEFT + MV_DIR_TO_BIT(direction);
 }
 
 static boolean JustBeingPushed(int x, int y)
@@ -5748,9 +5749,24 @@ void StartMoving(int x, int y)
       if (MovDir[x][y] & MV_HORIZONTAL && MovDir[x][y] & MV_VERTICAL &&
          ANDROID_CAN_ENTER_FIELD(element, newx, newy))
       {
+       int diagonal_move_dir = MovDir[x][y];
+       int change_delay = 8;
+       int graphic;
+
        /* android is moving diagonally */
 
-       CreateField(x, y, EL_EMC_ANDROID_SHRINKING);
+       CreateField(x, y, EL_DIAGONAL_SHRINKING);
+
+       GfxElement[x][y] = EL_EMC_ANDROID;
+       GfxAction[x][y] = ACTION_SHRINKING;
+       GfxDir[x][y] = diagonal_move_dir;
+       ChangeDelay[x][y] = change_delay;
+
+       graphic = el_act_dir2img(GfxElement[x][y], GfxAction[x][y],
+                                GfxDir[x][y]);
+
+       DrawLevelGraphicAnimation(x, y, graphic);
+       PlayLevelSoundAction(x, y, ACTION_SHRINKING);
 
 #if 0
        CheckTriggeredElementChangeBySide(x, y, element,
@@ -5762,7 +5778,19 @@ void StartMoving(int x, int y)
        TestIfElementTouchesCustomElement(newx, newy);
 #endif
 
-       CreateField(newx, newy, EL_EMC_ANDROID_GROWING);
+       CreateField(newx, newy, EL_DIAGONAL_GROWING);
+
+       Store[newx][newy] = EL_EMC_ANDROID;
+       GfxElement[newx][newy] = EL_EMC_ANDROID;
+       GfxAction[newx][newy] = ACTION_GROWING;
+       GfxDir[newx][newy] = diagonal_move_dir;
+       ChangeDelay[newx][newy] = change_delay;
+
+       graphic = el_act_dir2img(GfxElement[newx][newy], GfxAction[newx][newy],
+                                GfxDir[newx][newy]);
+
+       DrawLevelGraphicAnimation(newx, newy, graphic);
+       PlayLevelSoundAction(newx, newy, ACTION_GROWING);
 
        return;
       }
@@ -6863,9 +6891,11 @@ static void ActivateMagicBall(int bx, int by)
   game.ball_content_nr = (game.ball_content_nr + 1) % level.num_ball_contents;
 }
 
-static void InitAndroid(int x, int y)
+static void InitDiagonalMovingElement(int x, int y)
 {
+#if 0
   MovDelay[x][y] = level.android_move_time;
+#endif
 }
 
 void CheckExit(int x, int y)
@@ -7863,6 +7893,9 @@ static boolean ChangeElement(int x, int y, int element, int page)
   {
     target_element = GET_TARGET_ELEMENT(change->target_element, change);
 
+    if (element == EL_DIAGONAL_GROWING)
+      target_element = Store[x][y];
+
     CreateElementFromChange(x, y, target_element);
 
     PlayLevelSoundElementAction(x, y, element, ACTION_CHANGING);
@@ -8887,7 +8920,9 @@ void GameActions()
       CheckForDragon(x, y);
     else if (element == EL_EXPLOSION)
       ;        /* drawing of correct explosion animation is handled separately */
-    else if (element == EL_ELEMENT_SNAPPING)
+    else if (element == EL_ELEMENT_SNAPPING ||
+            element == EL_DIAGONAL_SHRINKING ||
+            element == EL_DIAGONAL_GROWING)
     {
 #if 1
       graphic = el_act_dir2img(GfxElement[x][y], GfxAction[x][y],GfxDir[x][y]);
@@ -10368,7 +10403,7 @@ void RemovePlayer(struct PlayerInfo *player)
 static void setFieldForSnapping(int x, int y, int element, int direction)
 {
   struct ElementInfo *ei = &element_info[element];
-  int direction_bit = MV_DIR_BIT(direction);
+  int direction_bit = MV_DIR_TO_BIT(direction);
   int graphic_snapping = ei->direction_graphic[ACTION_SNAPPING][direction_bit];
   int action = (graphic_snapping != IMG_EMPTY_SPACE ? ACTION_SNAPPING :
                IS_DIGGABLE(element) ? ACTION_DIGGING : ACTION_COLLECTING);