X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_em%2Fsynchro_1.c;h=b45330149723e044c168e83d1ed99bf46bbdbe85;hb=5fb4ddfd1d152d256f6b30e2dfeae0d14681893e;hp=1fe8faf0a99382bd7180381da190f358ffe2025f;hpb=28fe42eb060d7c9169a9b344678494e7d366a6b0;p=rocksndiamonds.git diff --git a/src/game_em/synchro_1.c b/src/game_em/synchro_1.c index 1fe8faf0..b4533014 100644 --- a/src/game_em/synchro_1.c +++ b/src/game_em/synchro_1.c @@ -5,13 +5,13 @@ * large switch statement for tiles the player interacts with. */ -#include "tile.h" -#include "level.h" -#include "sample.h" -#include "display.h" +#include "main_em.h" +#if 0 extern int centered_player_nr; +#endif + extern boolean checkIfAllPlayersFitToScreen(); static void check_player(struct PLAYER *); @@ -449,6 +449,8 @@ static void check_player(struct PLAYER *ply) int anim = 0; int dx = 0, dy = 0; + game_em.last_player_direction[ply->num] = MV_NONE; + #if 0 printf("::: up == %d, down == %d, left == %d, right == %d, fire == %d [spin == %d, stick == %d]\n", ply->joy_n, ply->joy_s, ply->joy_w, ply->joy_e, ply->joy_fire, @@ -546,12 +548,26 @@ static void check_player(struct PLAYER *ply) int oldy = ply->y; int x = oldx + dx; int y = oldy + dy; - boolean can_move = TRUE; + boolean players_visible_before_move; + boolean players_visible_after_move; + boolean can_move; + + players_visible_before_move = checkIfAllPlayersFitToScreen(); ply->x = x; ply->y = y; - can_move = (centered_player_nr != -1 || checkIfAllPlayersFitToScreen()); + players_visible_after_move = checkIfAllPlayersFitToScreen(); + + /* + player is allowed to move only in the following cases: + - it is not needed to display all players (not focussed to all players) + - all players are (still or again) visible after the move + - some players were already outside visible screen area before the move + */ + can_move = (game.centered_player_nr != -1 || + players_visible_after_move || + !players_visible_before_move); ply->x = oldx; ply->y = oldy;