FrameCounter = 0;
TimeFrames = 0;
TimeLeft = level.time;
+
+ ScreenMovDir = MV_NO_MOVING;
ScreenMovPos = 0;
+ ScreenGfxPos = 0;
AllPlayersGone = SiebAktiv = FALSE;
for(i=0; i<MAX_PLAYERS; i++)
{
+ /* TEST TEST TEST */
+
+ if (i != TestPlayer)
+ continue;
+
+ /* TEST TEST TEST */
+
PlayerActions(&stored_player[i], player_action);
- ScrollFigure(&stored_player[i], SCROLL_FIGURE_GO_ON);
+ ScrollFigure(&stored_player[i], SCROLL_GO_ON);
}
+ ScrollScreen(NULL, SCROLL_GO_ON);
+
if (tape.pausing || (tape.playing && !TapePlayDelay()))
return;
else if (tape.recording)
DrawAllPlayers();
}
+static BOOL AllPlayersInSight(struct PlayerInfo *player, int x, int y)
+{
+ int min_x = x, min_y = y, max_x = x, max_y = y;
+ int i;
+
+ for(i=0; i<MAX_PLAYERS; i++)
+ {
+ int jx = stored_player[i].jx, jy = stored_player[i].jy;
+
+ if (!stored_player[i].active || stored_player[i].gone ||
+ &stored_player[i] == player)
+ continue;
+
+ min_x = MIN(min_x, jx);
+ min_y = MIN(min_y, jy);
+ max_x = MAX(max_x, jx);
+ max_y = MAX(max_y, jy);
+ }
+
+ return(max_x - min_x < SCR_FIELDX && max_y - min_y < SCR_FIELDY);
+}
+
+static BOOL AllPlayersInVisibleScreen()
+{
+ int i;
+
+ for(i=0; i<MAX_PLAYERS; i++)
+ {
+ int jx = stored_player[i].jx, jy = stored_player[i].jy;
+
+ if (!stored_player[i].active || stored_player[i].gone)
+ continue;
+
+ if (!IN_VIS_FIELD(SCREENX(jx), SCREENY(jy)))
+ return(FALSE);
+ }
+
+ return(TRUE);
+}
+
void ScrollLevel(int dx, int dy)
{
int softscroll_offset = (soft_scrolling_on ? TILEX : 0);
int x,y;
- ScreenMovPos = local_player->GfxPos;
+ /*
+ ScreenGfxPos = local_player->GfxPos;
+ */
XCopyArea(display,drawto_field,drawto_field,gc,
FX + TILEX*(dx==-1) - softscroll_offset,
if (!IN_LEV_FIELD(new_jx,new_jy))
return(MF_NO_ACTION);
+ if (!networking && !AllPlayersInSight(player, new_jx,new_jy))
+ return(MF_NO_ACTION);
+
element = MovingOrBlocked2Element(new_jx,new_jy);
if (DONT_GO_TO(element))
player->MovPos = (dx > 0 || dy > 0 ? -1 : 1) * 7*TILEX/8;
- ScrollFigure(player, SCROLL_FIGURE_INIT);
+ ScrollFigure(player, SCROLL_INIT);
return(MF_MOVING);
}
jx = player->jx;
jy = player->jy;
+
+
+ /*
if (moved & MF_MOVING && player == local_player)
+ */
+
+ if (moved & MF_MOVING && !ScreenMovPos)
{
int old_scroll_x = scroll_x, old_scroll_y = scroll_y;
int offset = (scroll_delay_on ? 3 : 0);
- if ((scroll_x < jx-MIDPOSX-offset || scroll_x > jx-MIDPOSX+offset) &&
- jx >= MIDPOSX-1-offset && jx <= lev_fieldx-(MIDPOSX-offset))
- scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : offset);
- if ((scroll_y < jy-MIDPOSY-offset || scroll_y > jy-MIDPOSY+offset) &&
- jy >= MIDPOSY-1-offset && jy <= lev_fieldy-(MIDPOSY-offset))
- scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : offset);
+ if (!IN_VIS_FIELD(SCREENX(jx),SCREENY(jy)))
+ {
+ /* actual player has left the screen -- scroll in that direction */
+ if (jx != old_jx) /* player has moved horizontally */
+ scroll_x += (jx - old_jx);
+ else /* player has moved vertically */
+ scroll_y += (jy - old_jy);
+ }
+ else
+ {
+ if (jx != old_jx) /* player has moved horizontally */
+ {
+ if ((scroll_x < jx-MIDPOSX-offset || scroll_x > jx-MIDPOSX+offset) &&
+ jx >= MIDPOSX-1-offset && jx <= lev_fieldx-(MIDPOSX-offset))
+ scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : offset);
+
+ /* don't scroll more than one field at a time */
+ scroll_x = old_scroll_x + SIGN(scroll_x - old_scroll_x);
+
+ /* don't scroll against the player's moving direction */
+ if ((player->MovDir == MV_LEFT && scroll_x > old_scroll_x) ||
+ (player->MovDir == MV_RIGHT && scroll_x < old_scroll_x))
+ scroll_x = old_scroll_x;
+ }
+ else /* player has moved vertically */
+ {
+ if ((scroll_y < jy-MIDPOSY-offset || scroll_y > jy-MIDPOSY+offset) &&
+ jy >= MIDPOSY-1-offset && jy <= lev_fieldy-(MIDPOSY-offset))
+ scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : offset);
+
+ /* don't scroll more than one field at a time */
+ scroll_y = old_scroll_y + SIGN(scroll_y - old_scroll_y);
+
+ /* don't scroll against the player's moving direction */
+ if ((player->MovDir == MV_UP && scroll_y > old_scroll_y) ||
+ (player->MovDir == MV_DOWN && scroll_y < old_scroll_y))
+ scroll_y = old_scroll_y;
+ }
+ }
+
+#if 0
+ if (player == local_player)
+ {
+ if ((scroll_x < jx-MIDPOSX-offset || scroll_x > jx-MIDPOSX+offset) &&
+ jx >= MIDPOSX-1-offset && jx <= lev_fieldx-(MIDPOSX-offset))
+ scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : offset);
+ if ((scroll_y < jy-MIDPOSY-offset || scroll_y > jy-MIDPOSY+offset) &&
+ jy >= MIDPOSY-1-offset && jy <= lev_fieldy-(MIDPOSY-offset))
+ scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : offset);
+
+ /* don't scroll more than one field at a time */
+ scroll_x = old_scroll_x + SIGN(scroll_x - old_scroll_x);
+ scroll_y = old_scroll_y + SIGN(scroll_y - old_scroll_y);
+ }
+#endif
if (scroll_x != old_scroll_x || scroll_y != old_scroll_y)
- ScrollLevel(old_scroll_x - scroll_x, old_scroll_y - scroll_y);
+ {
+ if (networking || AllPlayersInVisibleScreen())
+ {
+ ScrollScreen(player, SCROLL_INIT);
+
+ /*
+ ScreenMovDir = player->MovDir;
+ ScreenMovPos = player->MovPos;
+ ScreenGfxPos = ScrollStepSize * (ScreenMovPos / ScrollStepSize);
+ */
+
+ ScrollLevel(old_scroll_x - scroll_x, old_scroll_y - scroll_y);
+ }
+ else
+ {
+ scroll_x = old_scroll_x;
+ scroll_y = old_scroll_y;
+ }
+ }
}
if (!(moved & MF_MOVING) && !player->Pushing)
if (!player->active || player->gone || !player->MovPos)
return;
- if (mode == SCROLL_FIGURE_INIT)
+ if (mode == SCROLL_INIT)
{
player->actual_frame_counter = FrameCounter;
player->GfxPos = ScrollStepSize * (player->MovPos / ScrollStepSize);
+ /*
+ ScreenGfxPos = local_player->GfxPos;
+ */
+
if (Feld[last_jx][last_jy] == EL_LEERRAUM)
Feld[last_jx][last_jy] = EL_PLAYER_IS_LEAVING;
player->MovPos += (player->MovPos > 0 ? -1 : 1) * TILEX/8;
player->GfxPos = ScrollStepSize * (player->MovPos / ScrollStepSize);
- if (ScreenMovPos && ScreenMovPos != local_player->GfxPos)
+ /*
+ if (ScreenMovPos)
{
- ScreenMovPos = local_player->GfxPos;
+ ScreenMovPos += (ScreenMovPos > 0 ? -1 : 1) * TILEX/8;
+ ScreenGfxPos = ScrollStepSize * (ScreenMovPos / ScrollStepSize);
+ }
+ */
+
+ /*
+ if (ScreenGfxPos && ScreenGfxPos != local_player->GfxPos)
+ {
+ ScreenGfxPos = local_player->GfxPos;
redraw_mask |= REDRAW_FIELD;
}
+ */
if (Feld[last_jx][last_jy] == EL_PLAYER_IS_LEAVING)
Feld[last_jx][last_jy] = EL_LEERRAUM;
}
}
+void ScrollScreen(struct PlayerInfo *player, int mode)
+{
+ static long screen_frame_counter = 0;
+
+ if (mode == SCROLL_INIT)
+ {
+ screen_frame_counter = FrameCounter;
+ ScreenMovDir = player->MovDir;
+ ScreenMovPos = player->MovPos;
+ ScreenGfxPos = ScrollStepSize * (ScreenMovPos / ScrollStepSize);
+ return;
+ }
+ else if (!FrameReached(&screen_frame_counter,1))
+ return;
+
+ if (ScreenMovPos)
+ {
+ /*
+ printf("ScreenMovDir = %d, ", ScreenMovDir);
+ printf("ScreenMovPos = %d, ", ScreenMovPos);
+ printf("ScreenGfxPos = %d\n", ScreenGfxPos);
+ */
+
+ ScreenMovPos += (ScreenMovPos > 0 ? -1 : 1) * TILEX/8;
+ ScreenGfxPos = ScrollStepSize * (ScreenMovPos / ScrollStepSize);
+ redraw_mask |= REDRAW_FIELD;
+ }
+ else
+ ScreenMovDir = MV_NO_MOVING;
+}
+
void TestIfGoodThingHitsBadThing(int goodx, int goody)
{
int i, killx = goodx, killy = goody;
#define SCREENY(a) ((a) - scroll_y)
#define LEVELX(a) ((a) + scroll_x)
#define LEVELY(a) ((a) + scroll_y)
+#define IN_VIS_FIELD(x,y) ((x)>=0 && (x)<SCR_FIELDX && (y)>=0 &&(y)<SCR_FIELDY)
#define IN_SCR_FIELD(x,y) ((x)>=BX1 && (x)<=BX2 && (y)>=BY1 &&(y)<=BY2)
#define IN_LEV_FIELD(x,y) ((x)>=0 && (x)<lev_fieldx && (y)>=0 &&(y)<lev_fieldy)
int level_nr;
int jx,jy, last_jx,last_jy;
- int MovDir, MovPos, Pushing;
- int Frame, GfxPos;
+ int MovDir, MovPos, GfxPos;
+ int Pushing, Frame;
int gone, LevelSolved, GameOver;
extern int autorecord_on;
extern int joystick_nr;
extern int quick_doors;
+extern int networking;
extern BOOL redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
extern int redraw_x1, redraw_y1;
extern int level_nr, leveldir_nr, num_leveldirs;
extern int lev_fieldx,lev_fieldy, scroll_x,scroll_y;
-extern int FX,FY, ScreenMovPos, ScrollStepSize;
+extern int FX,FY, ScrollStepSize;
+extern int ScreenMovDir, ScreenMovPos, ScreenGfxPos;
extern int GameFrameDelay, MoveSpeed;
extern int BX1,BY1, BX2,BY2;
extern int ZX,ZY, ExitX,ExitY;
extern int FrameCounter, TimeFrames, TimeLeft;
extern int MampferNr, SiebAktiv;
+extern int TestPlayer;
+
extern struct LevelDirInfo leveldir[];
extern struct LevelInfo level;
extern struct PlayerInfo stored_player[];
if (redraw_mask & REDRAW_TILES && redraw_tiles > REDRAWTILES_THRESHOLD)
redraw_mask |= REDRAW_FIELD;
- if (redraw_mask & REDRAW_FIELD || ScreenMovPos)
+ if (redraw_mask & REDRAW_FIELD || ScreenGfxPos)
redraw_mask &= ~REDRAW_TILES;
if (!redraw_mask)
if (soft_scrolling_on)
{
- fx += (local_player->MovDir & (MV_LEFT|MV_RIGHT) ? ScreenMovPos : 0);
- fy += (local_player->MovDir & (MV_UP|MV_DOWN) ? ScreenMovPos : 0);
+ fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0);
+ fy += (ScreenMovDir & (MV_UP|MV_DOWN) ? ScreenGfxPos : 0);
}
XCopyArea(display,buffer,window,gc,
if (direct_draw_on)
{
- int dest_x = SX + sx*TILEX;
- int dest_y = SY + sy*TILEY;
- int x_size = TILEX;
- int y_size = TILEY;
-
- if (!ScreenMovPos)
- {
- dest_x = SX + SCREENX(MIN(jx,last_jx))*TILEX;
- dest_y = SY + SCREENY(MIN(jy,last_jy))*TILEY;
- x_size = TILEX * (1 + ABS(jx - last_jx));
- y_size = TILEY * (1 + ABS(jy - last_jy));
- }
+ int dest_x = SX + SCREENX(MIN(jx,last_jx))*TILEX;
+ int dest_y = SY + SCREENY(MIN(jy,last_jy))*TILEY;
+ int x_size = TILEX * (1 + ABS(jx - last_jx));
+ int y_size = TILEY * (1 + ABS(jy - last_jy));
XCopyArea(display,drawto_field,window,gc,
dest_x,dest_y, x_size,y_size, dest_x,dest_y);