struct GraphicInfo_EM graphic_info_em_object[GAME_TILE_MAX][8];
struct GraphicInfo_EM graphic_info_em_player[MAX_PLAYERS][PLY_MAX][8];
+static struct XY xy_topdown[] =
+{
+ { 0, -1 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, +1 }
+};
+
+static void setScreenCenteredToAllPlayers(int *, int *);
+
int getFieldbufferOffsetX_EM(void)
{
return screen_x % TILEX;
int x, y, i;
int left = screen_x / TILEX;
int top = screen_y / TILEY;
- static int xy[4][2] =
- {
- { 0, -1 },
- { -1, 0 },
- { +1, 0 },
- { 0, +1 }
- };
+ struct XY *xy = xy_topdown;
if (!game.use_native_emc_graphics_engine)
for (y = lev.top; y < lev.bottom; y++)
{
for (i = 0; i < 4; i++)
{
- int xx = x + xy[i][0];
- int yy = y + xy[i][1];
+ int xx = x + xy[i].x;
+ int yy = y + xy[i].y;
int tile_next;
if (xx < 0 || xx >= CAVE_BUFFER_WIDTH ||
* handles transparency and movement
*/
-static void blitplayer(int nr)
+static void blitplayer_ext(int nr)
{
int x1, y1, x2, y2;
}
}
+static void blitplayer(int nr)
+{
+ blitplayer_ext(nr);
+
+ /* check for wrap-around movement ... */
+ if (ply[nr].x < lev.left ||
+ ply[nr].x > lev.right - 1)
+ {
+ struct PLAYER ply_last = ply[nr];
+ int direction = (ply[nr].x < lev.left ? -1 : 1);
+ int dx = ply[nr].x - ply[nr].prev_x;
+
+ ply[nr].x += -direction * lev.width;
+ ply[nr].prev_x = ply[nr].x - dx;
+
+ if (!lev.infinite_true)
+ {
+ int dy = ply[nr].y - ply[nr].prev_y;
+
+ ply[nr].y += direction;
+ ply[nr].prev_y = ply[nr].y - dy;
+ }
+
+ /* draw player entering playfield from the opposite side */
+ blitplayer_ext(nr);
+
+ /* ... but keep the old player position until game logic */
+ ply[nr] = ply_last;
+ }
+}
+
void game_initscreen(void)
{
- int player_nr;
- int x,y;
+ int x, y, sx, sy;
frame = 1;
- player_nr = (game.centered_player_nr != -1 ? game.centered_player_nr : 0);
+ if (game.centered_player_nr == -1)
+ {
+ setScreenCenteredToAllPlayers(&sx, &sy);
+ }
+ else
+ {
+ sx = PLAYER_SCREEN_X(game.centered_player_nr);
+ sy = PLAYER_SCREEN_Y(game.centered_player_nr);
+ }
- screen_x = VALID_SCREEN_X(PLAYER_SCREEN_X(player_nr));
- screen_y = VALID_SCREEN_Y(PLAYER_SCREEN_Y(player_nr));
+ screen_x = VALID_SCREEN_X(sx);
+ screen_y = VALID_SCREEN_Y(sy);
for (y = 0; y < MAX_BUF_YSIZE; y++)
{
boolean checkIfAllPlayersFitToScreen(void)
{
int sx1 = 0, sy1 = 0, sx2 = 0, sy2 = 0;
+ int scr_fieldx = getScreenFieldSizeX();
+ int scr_fieldy = getScreenFieldSizeY();
setMinimalPlayerBoundaries(&sx1, &sy1, &sx2, &sy2);
- return (sx2 - sx1 <= SCR_FIELDX * TILEX &&
- sy2 - sy1 <= SCR_FIELDY * TILEY);
+ return (sx2 - sx1 <= scr_fieldx * TILEX &&
+ sy2 - sy1 <= scr_fieldy * TILEY);
}
static void setScreenCenteredToAllPlayers(int *sx, int *sy)
if (draw_new_player_location_wrap)
{
- // when wrapping around (horizontally), keep vertical player position
- screen_yy = screen_y;
+ if (lev.infinite_true)
+ {
+ // when wrapping around (horizontally), keep vertical player position
+ screen_yy = screen_y;
+ }
// scrolling for wrapping should be faster than for switching players
wait_delay_value /= 4;