player->is_pushing = FALSE;
player->is_switching = FALSE;
player->is_dropping = FALSE;
+ player->is_dropping_pressed = FALSE;
player->is_bored = FALSE;
player->is_sleeping = FALSE;
player->push_delay_value = game.initial_push_delay_value;
player->drop_delay = 0;
+ player->drop_pressed_delay = 0;
player->last_jx = player->last_jy = 0;
player->jx = player->jy = 0;
int down = player_action & JOY_DOWN;
int button1 = player_action & JOY_BUTTON_1;
int button2 = player_action & JOY_BUTTON_2;
- int dx = (left ? -1 : right ? 1 : 0);
- int dy = (up ? -1 : down ? 1 : 0);
+ int dx = (left ? -1 : right ? 1 : 0);
+ int dy = (up ? -1 : down ? 1 : 0);
if (!player->active || tape.pausing)
return 0;
player->is_moving = FALSE;
player->is_dropping = FALSE;
+ player->is_dropping_pressed = FALSE;
+ player->drop_pressed_delay = 0;
return 0;
}
if (stored_player[i].drop_delay > 0)
stored_player[i].drop_delay--;
+
+ if (stored_player[i].is_dropping_pressed)
+ stored_player[i].drop_pressed_delay++;
}
}
player->is_snapping = FALSE;
player->is_switching = FALSE;
player->is_dropping = FALSE;
+ player->is_dropping_pressed = FALSE;
+ player->drop_pressed_delay = 0;
}
else
{
}
player->is_dropping = FALSE;
+ player->is_dropping_pressed = FALSE;
+ player->drop_pressed_delay = 0;
if (DigField(player, jx, jy, x, y, 0, 0, DF_SNAP) == MP_NO_ACTION)
return FALSE;
EL_DYNABOMB_PLAYER_1_ACTIVE + player->index_nr :
EL_UNDEFINED);
+ player->is_dropping_pressed = TRUE;
+
/* do not drop an element on top of another element; when holding drop key
pressed without moving, dropped element must move away before the next
element can be dropped (this is especially important if the next element
if (new_element == EL_UNDEFINED)
return FALSE;
+ /* check if drop key was pressed long enough for EM style dynamite */
+ if (new_element == EL_EM_DYNAMITE && player->drop_pressed_delay < 40)
+ return FALSE;
+
/* check if anything can be dropped at the current position */
if (IS_ACTIVE_BOMB(old_element) || old_element == EL_EXPLOSION)
return FALSE;
player->drop_delay = GET_NEW_DROP_DELAY(drop_element);
player->is_dropping = TRUE;
+ player->drop_pressed_delay = 0;
+ player->is_dropping_pressed = FALSE;
+
player->drop_x = dropx;
player->drop_y = dropy;
static boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
+#if 1
+int centered_player_nr;
+#else
static int centered_player_nr;
+#endif
/* copy the entire screen to the window at the scroll position */
*sy = (sy1 + sy2) / 2;
}
-void setMaxCenterDistanceForAllPlayers(int *max_dx, int *max_dy)
+void setMaxCenterDistanceForAllPlayers(int *max_dx, int *max_dy,
+ int center_x, int center_y)
{
- int sx1 = screen_x, sy1 = screen_y, sx2 = screen_x, sy2 = screen_y;
+ int sx1 = center_x, sy1 = center_y, sx2 = center_x, sy2 = center_y;
setMinimalPlayerBoundaries(&sx1, &sy1, &sx2, &sy2);
- *max_dx = MAX(ABS(sx1 - screen_x), ABS(sx2 - screen_x));
- *max_dy = MAX(ABS(sy1 - screen_y), ABS(sy2 - screen_y));
+ *max_dx = MAX(ABS(sx1 - center_x), ABS(sx2 - center_x));
+ *max_dy = MAX(ABS(sy1 - center_y), ABS(sy2 - center_y));
}
-boolean checkIfAllPlayersAreVisible()
+boolean checkIfAllPlayersAreVisible(int center_x, int center_y)
{
int max_dx, max_dy;
- setMaxCenterDistanceForAllPlayers(&max_dx, &max_dy);
+ setMaxCenterDistanceForAllPlayers(&max_dx, &max_dy, center_x, center_y);
return (max_dx <= SCR_FIELDX * TILEX / 2 &&
max_dy <= SCR_FIELDY * TILEY / 2);
void RedrawPlayfield_EM(boolean force_redraw)
{
+#if 0
boolean all_players_visible = checkIfAllPlayersAreVisible();
+#endif
boolean all_players_fit_to_screen = checkIfAllPlayersFitToScreen();
boolean draw_new_player_location = FALSE;
boolean quick_relocation = setup.quick_switch;
+#if 0
boolean scrolling = (screen_x % TILEX != 0 || screen_y % TILEY != 0);
+#endif
int centered_player_nr_next = getCenteredPlayerNr_EM();
int offset = (setup.scroll_delay ? 3 : 0) * TILEX;
int offset_x = offset;
centered_player_nr_next = centered_player_nr;
}
-#if 0
+#if 1
+ /* also allow focus switching when screen is scrolled to half tile */
+#else
if (!scrolling) /* screen currently aligned at tile position */
#endif
{
if (dx == 0 && dy == 0) /* no scrolling needed at all */
break;
+#if 1
+
+ if (ABS(screen_xx - screen_x) >= TILEX)
+ {
+ screen_x -= dx * TILEX;
+ dxx = dx * TILEX / 2;
+ }
+ else
+ {
+ screen_x = screen_xx;
+ dxx = 0;
+ }
+
+ if (ABS(screen_yy - screen_y) >= TILEY)
+ {
+ screen_y -= dy * TILEY;
+ dyy = dy * TILEY / 2;
+ }
+ else
+ {
+ screen_y = screen_yy;
+ dyy = 0;
+ }
+
+#else
+
#if 1
if (ABS(screen_xx - screen_x) >= TILEX ||
ABS(screen_yy - screen_y) >= TILEY)
dxx += dx * TILEX / 2;
dyy += dy * TILEY / 2;
+#endif
+
#endif
/* scroll in two steps of half tile size to make things smoother */
/* prevent scrolling away from the other players when focus on all players */
if (centered_player_nr == -1)
{
- all_players_visible = checkIfAllPlayersAreVisible();
+#if 1
+ /* check if all players are still visible with new scrolling position */
+ if (!checkIfAllPlayersAreVisible(screen_x, screen_y))
+ {
+ /* reset horizontal scroll position to last value, if needed */
+ if (!checkIfAllPlayersAreVisible(screen_x, screen_y_old))
+ screen_x = screen_x_old;
+
+ /* reset vertical scroll position to last value, if needed */
+ if (!checkIfAllPlayersAreVisible(screen_x_old, screen_y))
+ screen_y = screen_y_old;
+ }
+#else
+ boolean all_players_visible = checkIfAllPlayersAreVisible();
if (!all_players_visible)
{
+ printf("::: not all players visible\n");
+
screen_x = screen_x_old;
screen_y = screen_y_old;
}
+#endif
}
/* prevent scrolling (for screen correcting) if no player is moving */
int dx = SIGN(screen_x - screen_x_old);
int dy = SIGN(screen_y - screen_y_old);
- if ((dx < 0 && player_move_dir == MV_RIGHT) ||
- (dx > 0 && player_move_dir == MV_LEFT))
+ if ((dx < 0 && player_move_dir != MV_LEFT) ||
+ (dx > 0 && player_move_dir != MV_RIGHT))
screen_x = screen_x_old;
- if ((dy < 0 && player_move_dir == MV_DOWN) ||
- (dy > 0 && player_move_dir == MV_UP))
+ if ((dy < 0 && player_move_dir != MV_UP) ||
+ (dy > 0 && player_move_dir != MV_DOWN))
screen_y = screen_y_old;
}
#include "display.h"
+extern int centered_player_nr;
+extern boolean checkIfAllPlayersFitToScreen();
+
static void check_player(struct PLAYER *);
static void kill_player(struct PLAYER *);
static boolean player_digfield(struct PLAYER *, int, int);
}
#endif
+ if (dx || dy)
+ {
+ int oldx = ply->x;
+ int oldy = ply->y;
+ int x = oldx + dx;
+ int y = oldy + dy;
+ boolean can_move = TRUE;
+
+ ply->x = x;
+ ply->y = y;
+
+ can_move = (centered_player_nr != -1 || checkIfAllPlayersFitToScreen());
+
+ ply->x = oldx;
+ ply->y = oldy;
+
+ if (!can_move)
+ {
+ ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0;
+
+ return;
+ }
+ }
+
if (dx == 0 && dy == 0)
{
ply->joy_stick = 0;
ply->joy_stick = 1;
ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0;
- ply->dynamite_cnt = 0; /* reset dynamite timer if we move */
+ ply->dynamite_cnt = 0; /* reset dynamite timer if we move */
ply->joy_spin = !ply->joy_spin;
if (ply->joy_snap == 0) /* player wants to move */