rnd-20060320-1-src
authorHolger Schemel <info@artsoft.org>
Mon, 20 Mar 2006 22:40:28 +0000 (23:40 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:51:15 +0000 (10:51 +0200)
src/conftime.h
src/game_em/graphics.c
src/game_em/synchro_1.c

index ab9357c793217a88441a096f4cf66805c95ac9b9..67a4fe6b2773ccceed5ebc730932ea436df2cb61 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2006-03-19 20:13]"
+#define COMPILE_DATE_STRING "[2006-03-20 23:36]"
index 2935096df72837bce39b572704bd103c2d39f1c0..649a258a86bc98a7694f162db566e9e9bd49fe2c 100644 (file)
@@ -694,6 +694,7 @@ void RedrawPlayfield_EM(boolean force_redraw)
 #else
   int player_nr = game_em.last_moving_player;
 #endif
+  int stepsize = TILEX / 8;
   int offset = (setup.scroll_delay ? 3 : 0) * TILEX;
   int offset_x = offset;
   int offset_y = offset;
@@ -745,7 +746,11 @@ void RedrawPlayfield_EM(boolean force_redraw)
 
   if (game.centered_player_nr == -1)
   {
+#if 1
+    if (draw_new_player_location || offset == 0)
+#else
     if (draw_new_player_location)
+#endif
     {
       setScreenCenteredToAllPlayers(&sx, &sy);
     }
@@ -906,23 +911,37 @@ void RedrawPlayfield_EM(boolean force_redraw)
                            sy - offset_y > screen_y ? sy - offset_y :
                            screen_y);
 
-  /* prevent scrolling further than player step size screen when scrolling */
-  if (ABS(screen_x - screen_x_old) > TILEX / 8 ||
-      ABS(screen_y - screen_y_old) > TILEY / 8)
+#if 1
+  /* prevent scrolling further than double player step size when scrolling */
+  if (ABS(screen_x - screen_x_old) > 2 * stepsize ||
+      ABS(screen_y - screen_y_old) > 2 * stepsize)
   {
     int dx = SIGN(screen_x - screen_x_old);
     int dy = SIGN(screen_y - screen_y_old);
 
-    screen_x = screen_x_old + dx * TILEX / 8;
-    screen_y = screen_y_old + dy * TILEY / 8;
+    screen_x = screen_x_old + dx * 2 * stepsize;
+    screen_y = screen_y_old + dy * 2 * stepsize;
   }
+#else
+  /* prevent scrolling further than player step size when scrolling */
+  if (ABS(screen_x - screen_x_old) > stepsize ||
+      ABS(screen_y - screen_y_old) > stepsize)
+  {
+    int dx = SIGN(screen_x - screen_x_old);
+    int dy = SIGN(screen_y - screen_y_old);
+
+    screen_x = screen_x_old + dx * stepsize;
+    screen_y = screen_y_old + dy * stepsize;
+  }
+#endif
 
   /* prevent scrolling away from the other players when focus on all players */
   if (game.centered_player_nr == -1)
   {
 #if 1
     /* check if all players are still visible with new scrolling position */
-    if (!checkIfAllPlayersAreVisible(screen_x, screen_y))
+    if (checkIfAllPlayersAreVisible(screen_x_old, screen_y_old) &&
+       !checkIfAllPlayersAreVisible(screen_x, screen_y))
     {
       /* reset horizontal scroll position to last value, if needed */
       if (!checkIfAllPlayersAreVisible(screen_x, screen_y_old))
index 38607713370c2cf3e6e136aefc48e8dabd85d2ae..b45330149723e044c168e83d1ed99bf46bbdbe85 100644 (file)
@@ -548,13 +548,26 @@ static void check_player(struct PLAYER *ply)
     int oldy = ply->y;
     int x = oldx + dx;
     int y = oldy + dy;
-    boolean can_move = TRUE;
+    boolean players_visible_before_move;
+    boolean players_visible_after_move;
+    boolean can_move;
+
+    players_visible_before_move = checkIfAllPlayersFitToScreen();
 
     ply->x = x;
     ply->y = y;
 
+    players_visible_after_move = checkIfAllPlayersFitToScreen();
+
+    /*
+      player is allowed to move only in the following cases:
+      - it is not needed to display all players (not focussed to all players)
+      - all players are (still or again) visible after the move
+      - some players were already outside visible screen area before the move
+    */
     can_move = (game.centered_player_nr != -1 ||
-               checkIfAllPlayersFitToScreen());
+               players_visible_after_move ||
+               !players_visible_before_move);
 
     ply->x = oldx;
     ply->y = oldy;