removed repeated code
authorHolger Schemel <info@artsoft.org>
Tue, 18 Feb 2020 17:05:10 +0000 (18:05 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 19 May 2020 16:19:58 +0000 (18:19 +0200)
src/game_em/graphics.c

index ac219b86feca0669c0d5dffbcf0b836b574c655f..d1567b4a7e9356e9291ecd2eec2f4deaf5c9d11c 100644 (file)
 #define VALID_SCREEN_Y(y)      ((y) < MIN_SCREEN_Y ? MIN_SCREEN_Y :    \
                                 (y) > MAX_SCREEN_Y ? MAX_SCREEN_Y : (y))
 
-#define PLAYER_SCREEN_X(p)     (((7 - frame) * ply[p].oldx +           \
-                                 (1 + frame) * ply[p].x) * TILEX / 8   \
-                                - ((SCR_FIELDX - 1) * TILEX) / 2)
-#define PLAYER_SCREEN_Y(p)     (((7 - frame) * ply[p].oldy +           \
-                                 (1 + frame) * ply[p].y) * TILEY / 8   \
-                                - ((SCR_FIELDY - 1) * TILEY) / 2)
+#define PLAYER_POS_X(nr)       (((7 - frame) * ply[nr].oldx +          \
+                                 (1 + frame) * ply[nr].x) * TILEX / 8)
+#define PLAYER_POS_Y(nr)       (((7 - frame) * ply[nr].oldy +          \
+                                 (1 + frame) * ply[nr].y) * TILEY / 8)
+
+#define PLAYER_SCREEN_X(nr)    (PLAYER_POS_X(nr) -                     \
+                                (SCR_FIELDX - 1) * TILEX / 2)
+#define PLAYER_SCREEN_Y(nr)    (PLAYER_POS_Y(nr) -                     \
+                                (SCR_FIELDY - 1) * TILEY / 2)
 
 #define USE_EXTENDED_GRAPHICS_ENGINE           1
 
@@ -377,8 +380,8 @@ static void blitplayer(int nr)
     return;
 
   /* x1/y1 are left/top and x2/y2 are right/down part of the player movement */
-  x1 = ((7 - frame) * ply[nr].oldx + (1 + frame) * ply[nr].x) * TILEX / 8;
-  y1 = ((7 - frame) * ply[nr].oldy + (1 + frame) * ply[nr].y) * TILEY / 8;
+  x1 = PLAYER_POS_X(nr);
+  y1 = PLAYER_POS_Y(nr);
   x2 = x1 + TILEX - 1;
   y2 = y1 + TILEY - 1;