1 /* 2000-08-13T14:36:17Z
3 * graphics manipulation crap
8 #define MIN_SCREEN_XPOS 1
9 #define MIN_SCREEN_YPOS 1
10 #define MAX_SCREEN_XPOS MAX(1, lev.width - (SCR_FIELDX - 1))
11 #define MAX_SCREEN_YPOS MAX(1, lev.height - (SCR_FIELDY - 1))
13 #define MIN_SCREEN_X (MIN_SCREEN_XPOS * TILEX)
14 #define MIN_SCREEN_Y (MIN_SCREEN_YPOS * TILEY)
15 #define MAX_SCREEN_X (MAX_SCREEN_XPOS * TILEX)
16 #define MAX_SCREEN_Y (MAX_SCREEN_YPOS * TILEY)
18 #define VALID_SCREEN_X(x) ((x) < MIN_SCREEN_X ? MIN_SCREEN_X : \
19 (x) > MAX_SCREEN_X ? MAX_SCREEN_X : (x))
20 #define VALID_SCREEN_Y(y) ((y) < MIN_SCREEN_Y ? MIN_SCREEN_Y : \
21 (y) > MAX_SCREEN_Y ? MAX_SCREEN_Y : (y))
23 #define PLAYER_SCREEN_X(p) ((( frame) * ply[p].oldx + \
24 (8 - frame) * ply[p].x) * TILEX / 8 \
25 - ((SCR_FIELDX - 1) * TILEX) / 2)
26 #define PLAYER_SCREEN_Y(p) ((( frame) * ply[p].oldy + \
27 (8 - frame) * ply[p].y) * TILEY / 8 \
28 - ((SCR_FIELDY - 1) * TILEY) / 2)
30 #define USE_EXTENDED_GRAPHICS_ENGINE 1
33 int frame; /* current screen frame */
34 int screen_x, screen_y; /* current scroll position */
36 /* tiles currently on screen */
37 static int screentiles[MAX_PLAYFIELD_HEIGHT + 2][MAX_PLAYFIELD_WIDTH + 2];
38 static int crumbled_state[MAX_PLAYFIELD_HEIGHT + 2][MAX_PLAYFIELD_WIDTH + 2];
39 static boolean redraw[MAX_PLAYFIELD_WIDTH + 2][MAX_PLAYFIELD_HEIGHT + 2];
41 /* copy the entire screen to the window at the scroll position */
43 void BlitScreenToBitmap_EM(Bitmap *target_bitmap)
45 int x = screen_x % (MAX_BUF_XSIZE * TILEX);
46 int y = screen_y % (MAX_BUF_YSIZE * TILEY);
47 int sx, sy, sxsize, sysize;
50 int full_xsize = lev.width * TILEX;
51 int full_ysize = lev.height * TILEY;
53 sxsize = (full_xsize < xsize ? full_xsize : xsize);
54 sysize = (full_ysize < ysize ? full_ysize : ysize);
55 sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0);
56 sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0);
58 if (x < 2 * TILEX && y < 2 * TILEY)
60 BlitBitmap(screenBitmap, target_bitmap, x, y,
61 sxsize, sysize, sx, sy);
63 else if (x < 2 * TILEX && y >= 2 * TILEY)
65 BlitBitmap(screenBitmap, target_bitmap, x, y,
66 sxsize, MAX_BUF_YSIZE * TILEY - y,
68 BlitBitmap(screenBitmap, target_bitmap, x, 0,
69 sxsize, y - 2 * TILEY,
70 sx, sy + MAX_BUF_YSIZE * TILEY - y);
72 else if (x >= 2 * TILEX && y < 2 * TILEY)
74 BlitBitmap(screenBitmap, target_bitmap, x, y,
75 MAX_BUF_XSIZE * TILEX - x, sysize,
77 BlitBitmap(screenBitmap, target_bitmap, 0, y,
78 x - 2 * TILEX, sysize,
79 sx + MAX_BUF_XSIZE * TILEX - x, sy);
83 BlitBitmap(screenBitmap, target_bitmap, x, y,
84 MAX_BUF_XSIZE * TILEX - x, MAX_BUF_YSIZE * TILEY - y,
86 BlitBitmap(screenBitmap, target_bitmap, 0, y,
87 x - 2 * TILEX, MAX_BUF_YSIZE * TILEY - y,
88 sx + MAX_BUF_XSIZE * TILEX - x, sy);
89 BlitBitmap(screenBitmap, target_bitmap, x, 0,
90 MAX_BUF_XSIZE * TILEX - x, y - 2 * TILEY,
91 sx, sy + MAX_BUF_YSIZE * TILEY - y);
92 BlitBitmap(screenBitmap, target_bitmap, 0, 0,
93 x - 2 * TILEX, y - 2 * TILEY,
94 sx + MAX_BUF_XSIZE * TILEX - x, sy + MAX_BUF_YSIZE * TILEY - y);
98 void BackToFront_EM(void)
102 /* blit all (up to four) parts of the scroll buffer to the backbuffer */
103 BlitScreenToBitmap_EM(backbuffer);
105 /* blit the completely updated backbuffer to the window (in one blit) */
106 BlitBitmap(backbuffer, window, SX, SY, SXSIZE, SYSIZE, SX, SY);
108 for (x = 0; x < MAX_BUF_XSIZE; x++)
109 for (y = 0; y < MAX_BUF_YSIZE; y++)
110 redraw[x][y] = FALSE;
114 void blitscreen(void)
119 static struct GraphicInfo_EM *getObjectGraphic(int x, int y)
121 int tile = Draw[y][x];
122 struct GraphicInfo_EM *g = &graphic_info_em_object[tile][frame];
124 if (!game.use_native_emc_graphics_engine)
125 getGraphicSourceObjectExt_EM(g, tile, 7 - frame, x - 2, y - 2);
130 static struct GraphicInfo_EM *getPlayerGraphic(int player_nr, int anim)
132 struct GraphicInfo_EM *g = &graphic_info_em_player[player_nr][anim][frame];
134 if (!game.use_native_emc_graphics_engine)
135 getGraphicSourcePlayerExt_EM(g, player_nr, anim, 7 - frame);
140 static void DrawLevelField_EM(int x, int y, int sx, int sy,
143 struct GraphicInfo_EM *g = getObjectGraphic(x, y);
144 int src_x = g->src_x + g->src_offset_x * TILESIZE_VAR / TILESIZE;
145 int src_y = g->src_y + g->src_offset_y * TILESIZE_VAR / TILESIZE;
146 int dst_x = sx * TILEX + g->dst_offset_x * TILESIZE_VAR / TILESIZE;
147 int dst_y = sy * TILEY + g->dst_offset_y * TILESIZE_VAR / TILESIZE;
148 int width = g->width * TILESIZE_VAR / TILESIZE;
149 int height = g->height * TILESIZE_VAR / TILESIZE;
150 int left = screen_x / TILEX;
151 int top = screen_y / TILEY;
153 /* do not draw fields that are outside the visible screen area */
154 if (x < left || x >= left + MAX_BUF_XSIZE ||
155 y < top || y >= top + MAX_BUF_YSIZE)
160 if (width > 0 && height > 0)
161 BlitBitmapMasked(g->bitmap, screenBitmap,
162 src_x, src_y, width, height, dst_x, dst_y);
166 if ((width != TILEX || height != TILEY) && !g->preserve_background)
167 ClearRectangle(screenBitmap, sx * TILEX, sy * TILEY, TILEX, TILEY);
169 if (width > 0 && height > 0)
170 BlitBitmap(g->bitmap, screenBitmap,
171 src_x, src_y, width, height, dst_x, dst_y);
175 static void DrawLevelFieldCrumbled_EM(int x, int y, int sx, int sy,
176 int crm, boolean draw_masked)
178 struct GraphicInfo_EM *g;
179 int crumbled_border_size;
180 int left = screen_x / TILEX;
181 int top = screen_y / TILEY;
184 /* do not draw fields that are outside the visible screen area */
185 if (x < left || x >= left + MAX_BUF_XSIZE ||
186 y < top || y >= top + MAX_BUF_YSIZE)
189 if (crm == 0) /* no crumbled edges for this tile */
192 g = getObjectGraphic(x, y);
194 crumbled_border_size = g->crumbled_border_size * TILESIZE_VAR / TILESIZE;
196 for (i = 0; i < 4; i++)
200 int width, height, cx, cy;
202 if (i == 1 || i == 2)
204 width = crumbled_border_size;
206 cx = (i == 2 ? TILEX - crumbled_border_size : 0);
212 height = crumbled_border_size;
214 cy = (i == 3 ? TILEY - crumbled_border_size : 0);
217 if (width > 0 && height > 0)
219 int src_x = g->crumbled_src_x + cx;
220 int src_y = g->crumbled_src_y + cy;
221 int dst_x = sx * TILEX + cx;
222 int dst_y = sy * TILEY + cy;
225 BlitBitmapMasked(g->crumbled_bitmap, screenBitmap,
226 src_x, src_y, width, height, dst_x, dst_y);
228 BlitBitmap(g->crumbled_bitmap, screenBitmap,
229 src_x, src_y, width, height, dst_x, dst_y);
235 static void DrawLevelPlayer_EM(int x1, int y1, int player_nr, int anim,
238 struct GraphicInfo_EM *g = getPlayerGraphic(player_nr, anim);
239 int src_x = g->src_x, src_y = g->src_y;
242 /* do not draw fields that are outside the visible screen area */
243 if (x1 < screen_x - TILEX || x1 >= screen_x + MAX_BUF_XSIZE * TILEX ||
244 y1 < screen_y - TILEY || y1 >= screen_y + MAX_BUF_YSIZE * TILEY)
247 x1 %= MAX_BUF_XSIZE * TILEX;
248 y1 %= MAX_BUF_YSIZE * TILEY;
252 /* draw the player to current location */
255 BlitBitmapMasked(g->bitmap, screenBitmap,
256 src_x, src_y, TILEX, TILEY, dst_x, dst_y);
258 /* draw the player to opposite wrap-around column */
259 dst_x = x1 - MAX_BUF_XSIZE * TILEX;
261 BlitBitmapMasked(g->bitmap, screenBitmap,
262 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
264 /* draw the player to opposite wrap-around row */
266 dst_y = y1 - MAX_BUF_YSIZE * TILEY;
267 BlitBitmapMasked(g->bitmap, screenBitmap,
268 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
272 /* draw the player to current location */
275 BlitBitmap(g->bitmap, screenBitmap,
276 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
278 /* draw the player to opposite wrap-around column */
279 dst_x = x1 - MAX_BUF_XSIZE * TILEX;
281 BlitBitmap(g->bitmap, screenBitmap,
282 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
284 /* draw the player to opposite wrap-around row */
286 dst_y = y1 - MAX_BUF_YSIZE * TILEY;
287 BlitBitmap(g->bitmap, screenBitmap,
288 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
292 /* draw differences between game tiles and screen tiles
294 * implicitly handles scrolling and restoring background under the sprites
297 static void animscreen(void)
300 int left = screen_x / TILEX;
301 int top = screen_y / TILEY;
302 static int xy[4][2] =
310 if (!game.use_native_emc_graphics_engine)
311 for (y = 2; y < EM_MAX_CAVE_HEIGHT - 2; y++)
312 for (x = 2; x < EM_MAX_CAVE_WIDTH - 2; x++)
313 SetGfxAnimation_EM(&graphic_info_em_object[Draw[y][x]][frame],
314 Draw[y][x], 7 - frame, x - 2, y - 2);
316 for (y = top; y < top + MAX_BUF_YSIZE; y++)
318 for (x = left; x < left + MAX_BUF_XSIZE; x++)
320 int sx = x % MAX_BUF_XSIZE;
321 int sy = y % MAX_BUF_YSIZE;
322 int tile = Draw[y][x];
323 struct GraphicInfo_EM *g = &graphic_info_em_object[tile][frame];
324 int obj = g->unique_identifier;
326 boolean redraw_screen_tile = FALSE;
328 /* re-calculate crumbled state of this tile */
329 if (g->has_crumbled_graphics)
331 for (i = 0; i < 4; i++)
333 int xx = x + xy[i][0];
334 int yy = y + xy[i][1];
337 if (xx < 0 || xx >= EM_MAX_CAVE_WIDTH ||
338 yy < 0 || yy >= EM_MAX_CAVE_HEIGHT)
341 tile_next = Draw[yy][xx];
343 if (!graphic_info_em_object[tile_next][frame].has_crumbled_graphics)
348 redraw_screen_tile = (screentiles[sy][sx] != obj ||
349 crumbled_state[sy][sx] != crm);
351 /* only redraw screen tiles if they (or their crumbled state) changed */
352 if (redraw_screen_tile)
354 DrawLevelField_EM(x, y, sx, sy, FALSE);
355 DrawLevelFieldCrumbled_EM(x, y, sx, sy, crm, FALSE);
357 screentiles[sy][sx] = obj;
358 crumbled_state[sy][sx] = crm;
360 redraw[sx][sy] = TRUE;
368 /* blit players to the screen
370 * handles transparency and movement
373 static void blitplayer(struct PLAYER *ply)
380 /* x1/y1 are left/top and x2/y2 are right/down part of the player movement */
381 x1 = (frame * ply->oldx + (8 - frame) * ply->x) * TILEX / 8;
382 y1 = (frame * ply->oldy + (8 - frame) * ply->y) * TILEY / 8;
386 if ((int)(x2 - screen_x) < ((MAX_BUF_XSIZE - 1) * TILEX - 1) &&
387 (int)(y2 - screen_y) < ((MAX_BUF_YSIZE - 1) * TILEY - 1))
389 /* some casts to "int" are needed because of negative calculation values */
390 int dx = (int)ply->x - (int)ply->oldx;
391 int dy = (int)ply->y - (int)ply->oldy;
392 int old_x = (int)ply->oldx + (7 - (int)frame) * dx / 8;
393 int old_y = (int)ply->oldy + (7 - (int)frame) * dy / 8;
394 int new_x = old_x + SIGN(dx);
395 int new_y = old_y + SIGN(dy);
396 int old_sx = old_x % MAX_BUF_XSIZE;
397 int old_sy = old_y % MAX_BUF_YSIZE;
398 int new_sx = new_x % MAX_BUF_XSIZE;
399 int new_sy = new_y % MAX_BUF_YSIZE;
400 int new_crm = crumbled_state[new_sy][new_sx];
402 /* only diggable elements can be crumbled in the classic EM engine */
403 boolean player_is_digging = (new_crm != 0);
405 if (player_is_digging)
407 /* draw the field the player is moving to (under the player) */
408 DrawLevelField_EM(new_x, new_y, new_sx, new_sy, FALSE);
409 DrawLevelFieldCrumbled_EM(new_x, new_y, new_sx, new_sy, new_crm, FALSE);
411 /* draw the player (masked) over the element he is just digging away */
412 DrawLevelPlayer_EM(x1, y1, ply->num, ply->anim, TRUE);
414 /* draw the field the player is moving from (masked over the player) */
415 DrawLevelField_EM(old_x, old_y, old_sx, old_sy, TRUE);
419 /* draw the player under the element which is on the same field */
420 DrawLevelPlayer_EM(x1, y1, ply->num, ply->anim, FALSE);
422 /* draw the field the player is moving from (masked over the player) */
423 DrawLevelField_EM(old_x, old_y, old_sx, old_sy, TRUE);
425 /* draw the field the player is moving to (masked over the player) */
426 DrawLevelField_EM(new_x, new_y, new_sx, new_sy, TRUE);
429 /* redraw screen tiles in the next frame (player may have left the tiles) */
430 screentiles[old_sy][old_sx] = -1;
431 screentiles[new_sy][new_sx] = -1;
433 /* mark screen tiles as dirty (force screen refresh with changed content) */
434 redraw[old_sx][old_sy] = TRUE;
435 redraw[new_sx][new_sy] = TRUE;
440 void game_initscreen(void)
447 player_nr = (game.centered_player_nr != -1 ? game.centered_player_nr : 0);
449 screen_x = VALID_SCREEN_X(PLAYER_SCREEN_X(player_nr));
450 screen_y = VALID_SCREEN_Y(PLAYER_SCREEN_Y(player_nr));
452 for (y = 0; y < MAX_BUF_YSIZE; y++)
454 for (x = 0; x < MAX_BUF_XSIZE; x++)
456 screentiles[y][x] = -1;
457 crumbled_state[y][x] = 0;
462 static int getMaxCenterDistancePlayerNr(int center_x, int center_y)
464 int max_dx = 0, max_dy = 0;
465 int player_nr = game_em.last_moving_player;
468 for (i = 0; i < MAX_PLAYERS; i++)
472 int sx = PLAYER_SCREEN_X(i);
473 int sy = PLAYER_SCREEN_Y(i);
475 if (game_em.last_player_direction[i] != MV_NONE &&
476 (ABS(sx - center_x) > max_dx ||
477 ABS(sy - center_y) > max_dy))
479 max_dx = MAX(max_dx, ABS(sx - center_x));
480 max_dy = MAX(max_dy, ABS(sy - center_y));
490 static void setMinimalPlayerBoundaries(int *sx1, int *sy1, int *sx2, int *sy2)
492 boolean num_checked_players = 0;
495 for (i = 0; i < MAX_PLAYERS; i++)
499 int sx = PLAYER_SCREEN_X(i);
500 int sy = PLAYER_SCREEN_Y(i);
502 if (num_checked_players == 0)
509 *sx1 = MIN(*sx1, sx);
510 *sy1 = MIN(*sy1, sy);
511 *sx2 = MAX(*sx2, sx);
512 *sy2 = MAX(*sy2, sy);
515 num_checked_players++;
520 boolean checkIfAllPlayersFitToScreen()
522 int sx1 = 0, sy1 = 0, sx2 = 0, sy2 = 0;
524 setMinimalPlayerBoundaries(&sx1, &sy1, &sx2, &sy2);
526 return (sx2 - sx1 <= SCR_FIELDX * TILEX &&
527 sy2 - sy1 <= SCR_FIELDY * TILEY);
530 static void setScreenCenteredToAllPlayers(int *sx, int *sy)
532 int sx1 = screen_x, sy1 = screen_y, sx2 = screen_x, sy2 = screen_y;
534 setMinimalPlayerBoundaries(&sx1, &sy1, &sx2, &sy2);
536 *sx = (sx1 + sx2) / 2;
537 *sy = (sy1 + sy2) / 2;
540 static void setMaxCenterDistanceForAllPlayers(int *max_dx, int *max_dy,
541 int center_x, int center_y)
543 int sx1 = center_x, sy1 = center_y, sx2 = center_x, sy2 = center_y;
545 setMinimalPlayerBoundaries(&sx1, &sy1, &sx2, &sy2);
547 *max_dx = MAX(ABS(sx1 - center_x), ABS(sx2 - center_x));
548 *max_dy = MAX(ABS(sy1 - center_y), ABS(sy2 - center_y));
551 static boolean checkIfAllPlayersAreVisible(int center_x, int center_y)
555 setMaxCenterDistanceForAllPlayers(&max_dx, &max_dy, center_x, center_y);
557 return (max_dx <= SCR_FIELDX * TILEX / 2 &&
558 max_dy <= SCR_FIELDY * TILEY / 2);
561 void RedrawPlayfield_EM(boolean force_redraw)
563 boolean draw_new_player_location = FALSE;
564 boolean quick_relocation = setup.quick_switch;
565 int max_center_distance_player_nr =
566 getMaxCenterDistancePlayerNr(screen_x, screen_y);
567 int stepsize = TILEX / 8;
568 int offset = game.scroll_delay_value * TILEX;
569 int offset_x = offset;
570 int offset_y = offset;
571 int screen_x_old = screen_x;
572 int screen_y_old = screen_y;
576 if (game.set_centered_player)
578 boolean all_players_fit_to_screen = checkIfAllPlayersFitToScreen();
580 /* switching to "all players" only possible if all players fit to screen */
581 if (game.centered_player_nr_next == -1 && !all_players_fit_to_screen)
583 game.centered_player_nr_next = game.centered_player_nr;
584 game.set_centered_player = FALSE;
587 /* do not switch focus to non-existing (or non-active) player */
588 if (game.centered_player_nr_next >= 0 &&
589 !ply[game.centered_player_nr_next].alive)
591 game.centered_player_nr_next = game.centered_player_nr;
592 game.set_centered_player = FALSE;
596 /* also allow focus switching when screen is scrolled to half tile */
597 if (game.set_centered_player)
599 game.centered_player_nr = game.centered_player_nr_next;
601 draw_new_player_location = TRUE;
604 game.set_centered_player = FALSE;
607 if (game.centered_player_nr == -1)
609 if (draw_new_player_location || offset == 0)
611 setScreenCenteredToAllPlayers(&sx, &sy);
615 sx = PLAYER_SCREEN_X(max_center_distance_player_nr);
616 sy = PLAYER_SCREEN_Y(max_center_distance_player_nr);
621 sx = PLAYER_SCREEN_X(game.centered_player_nr);
622 sy = PLAYER_SCREEN_Y(game.centered_player_nr);
625 if (draw_new_player_location && quick_relocation)
627 screen_x = VALID_SCREEN_X(sx);
628 screen_y = VALID_SCREEN_Y(sy);
629 screen_x_old = screen_x;
630 screen_y_old = screen_y;
633 if (draw_new_player_location && !quick_relocation)
635 unsigned int game_frame_delay_value = getGameFrameDelay_EM(20);
636 int wait_delay_value = game_frame_delay_value;
637 int screen_xx = VALID_SCREEN_X(sx);
638 int screen_yy = VALID_SCREEN_Y(sy);
640 while (screen_x != screen_xx || screen_y != screen_yy)
642 int dx = (screen_xx < screen_x ? +1 : screen_xx > screen_x ? -1 : 0);
643 int dy = (screen_yy < screen_y ? +1 : screen_yy > screen_y ? -1 : 0);
644 int dxx = 0, dyy = 0;
646 if (dx == 0 && dy == 0) /* no scrolling needed at all */
649 if (ABS(screen_xx - screen_x) >= TILEX)
651 screen_x -= dx * TILEX;
652 dxx = dx * TILEX / 2;
656 screen_x = screen_xx;
660 if (ABS(screen_yy - screen_y) >= TILEY)
662 screen_y -= dy * TILEY;
663 dyy = dy * TILEY / 2;
667 screen_y = screen_yy;
671 /* scroll in two steps of half tile size to make things smoother */
677 for (i = 0; i < MAX_PLAYERS; i++)
682 Delay(wait_delay_value);
684 /* scroll second step to align at full tile size */
690 for (i = 0; i < MAX_PLAYERS; i++)
695 Delay(wait_delay_value);
698 screen_x_old = screen_x;
699 screen_y_old = screen_y;
704 for (y = 0; y < MAX_BUF_YSIZE; y++)
706 for (x = 0; x < MAX_BUF_XSIZE; x++)
708 screentiles[y][x] = -1;
709 crumbled_state[y][x] = 0;
714 /* calculate new screen scrolling position, with regard to scroll delay */
715 screen_x = VALID_SCREEN_X(sx + offset_x < screen_x ? sx + offset_x :
716 sx - offset_x > screen_x ? sx - offset_x :
718 screen_y = VALID_SCREEN_Y(sy + offset_y < screen_y ? sy + offset_y :
719 sy - offset_y > screen_y ? sy - offset_y :
722 /* prevent scrolling further than double player step size when scrolling */
723 if (ABS(screen_x - screen_x_old) > 2 * stepsize)
725 int dx = SIGN(screen_x - screen_x_old);
727 screen_x = screen_x_old + dx * 2 * stepsize;
729 if (ABS(screen_y - screen_y_old) > 2 * stepsize)
731 int dy = SIGN(screen_y - screen_y_old);
733 screen_y = screen_y_old + dy * 2 * stepsize;
736 /* prevent scrolling away from the other players when focus on all players */
737 if (game.centered_player_nr == -1)
739 /* check if all players are still visible with new scrolling position */
740 if (checkIfAllPlayersAreVisible(screen_x_old, screen_y_old) &&
741 !checkIfAllPlayersAreVisible(screen_x, screen_y))
743 /* reset horizontal scroll position to last value, if needed */
744 if (!checkIfAllPlayersAreVisible(screen_x, screen_y_old))
745 screen_x = screen_x_old;
747 /* reset vertical scroll position to last value, if needed */
748 if (!checkIfAllPlayersAreVisible(screen_x_old, screen_y))
749 screen_y = screen_y_old;
753 /* prevent scrolling (for screen correcting) if no player is moving */
754 if (!game_em.any_player_moving)
756 screen_x = screen_x_old;
757 screen_y = screen_y_old;
761 /* prevent scrolling against the players move direction */
762 int player_nr = (game.centered_player_nr == -1 ?
763 max_center_distance_player_nr : game.centered_player_nr);
764 int player_move_dir = game_em.last_player_direction[player_nr];
765 int dx = SIGN(screen_x - screen_x_old);
766 int dy = SIGN(screen_y - screen_y_old);
768 if ((dx < 0 && player_move_dir != MV_LEFT) ||
769 (dx > 0 && player_move_dir != MV_RIGHT))
770 screen_x = screen_x_old;
772 if ((dy < 0 && player_move_dir != MV_UP) ||
773 (dy > 0 && player_move_dir != MV_DOWN))
774 screen_y = screen_y_old;
779 for (i = 0; i < MAX_PLAYERS; i++)
783 void game_animscreen(void)
785 RedrawPlayfield_EM(FALSE);