From: Holger Schemel Date: Wed, 8 Mar 2006 00:52:40 +0000 (+0100) Subject: rnd-20060308-1-src X-Git-Tag: 3.2.0^2~54 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=28fe42eb060d7c9169a9b344678494e7d366a6b0;p=rocksndiamonds.git rnd-20060308-1-src * added delayed ignition of EM style dynamite when used in R'n'D engine * added limited movement range to EMC engine when focus on all players --- diff --git a/ChangeLog b/ChangeLog index b9b13f22..04ad5186 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-03-08 + * added delayed ignition of EM style dynamite when used in R'n'D engine + * added limited movement range to EMC engine when focus on all players + 2006-03-06 * fixed bug with missing (zero) score values for native Supaplex levels diff --git a/src/conftime.h b/src/conftime.h index 828034f9..b9e8b44b 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-03-06 13:34]" +#define COMPILE_DATE_STRING "[2006-03-08 01:50]" diff --git a/src/game.c b/src/game.c index ce69ee18..8d919bc8 100644 --- a/src/game.c +++ b/src/game.c @@ -1834,6 +1834,7 @@ void InitGame() 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; @@ -1882,6 +1883,7 @@ void InitGame() 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; @@ -8710,8 +8712,8 @@ static byte PlayerActions(struct PlayerInfo *player, byte player_action) 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; @@ -8756,6 +8758,8 @@ static byte PlayerActions(struct PlayerInfo *player, byte player_action) player->is_moving = FALSE; player->is_dropping = FALSE; + player->is_dropping_pressed = FALSE; + player->drop_pressed_delay = 0; return 0; } @@ -8806,6 +8810,9 @@ void AdvanceFrameAndPlayerCounters(int player_nr) 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++; } } @@ -9934,6 +9941,8 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) player->is_snapping = FALSE; player->is_switching = FALSE; player->is_dropping = FALSE; + player->is_dropping_pressed = FALSE; + player->drop_pressed_delay = 0; } else { @@ -11633,6 +11642,8 @@ boolean SnapField(struct PlayerInfo *player, int dx, int dy) } 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; @@ -11668,6 +11679,8 @@ boolean DropElement(struct PlayerInfo *player) 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 @@ -11695,6 +11708,10 @@ boolean DropElement(struct PlayerInfo *player) 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; @@ -11782,6 +11799,9 @@ boolean DropElement(struct PlayerInfo *player) 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; diff --git a/src/game_em/graphics.c b/src/game_em/graphics.c index b6cad3c5..f623ac7a 100644 --- a/src/game_em/graphics.c +++ b/src/game_em/graphics.c @@ -40,7 +40,11 @@ static int crumbled_state[MAX_BUF_YSIZE][MAX_BUF_XSIZE]; 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 */ @@ -620,21 +624,22 @@ void setScreenCenteredToAllPlayers(int *sx, int *sy) *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); @@ -642,11 +647,15 @@ boolean checkIfAllPlayersAreVisible() 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; @@ -664,7 +673,9 @@ void RedrawPlayfield_EM(boolean force_redraw) 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 { @@ -715,6 +726,32 @@ void RedrawPlayfield_EM(boolean force_redraw) 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) @@ -739,6 +776,8 @@ void RedrawPlayfield_EM(boolean force_redraw) dxx += dx * TILEX / 2; dyy += dy * TILEY / 2; +#endif + #endif /* scroll in two steps of half tile size to make things smoother */ @@ -808,13 +847,29 @@ void RedrawPlayfield_EM(boolean force_redraw) /* 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 */ @@ -831,12 +886,12 @@ void RedrawPlayfield_EM(boolean force_redraw) 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; } diff --git a/src/game_em/synchro_1.c b/src/game_em/synchro_1.c index 147da4af..1fe8faf0 100644 --- a/src/game_em/synchro_1.c +++ b/src/game_em/synchro_1.c @@ -11,6 +11,9 @@ #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); @@ -537,6 +540,30 @@ static void check_player(struct PLAYER *ply) } #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; @@ -562,7 +589,7 @@ static void check_player(struct PLAYER *ply) 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 */ diff --git a/src/main.h b/src/main.h index ef613199..031727bc 100644 --- a/src/main.h +++ b/src/main.h @@ -1825,6 +1825,7 @@ struct PlayerInfo boolean is_pushing; boolean is_switching; boolean is_dropping; + boolean is_dropping_pressed; boolean is_bored; boolean is_sleeping; @@ -1860,6 +1861,7 @@ struct PlayerInfo unsigned long actual_frame_counter; int drop_delay; + int drop_pressed_delay; int step_counter;