X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fgame.c;h=3392e0ec441dc340dd7079932825f91896d253e1;hp=05af36f92b6a846193002ae345d09d1120cd68ff;hb=823bddb0d9cc63ddda17a2cd20266aa3b82bde38;hpb=f45528c08776cd2c87a83bf3ec7e1f7fe7b18765 diff --git a/src/game.c b/src/game.c index 05af36f9..3392e0ec 100644 --- a/src/game.c +++ b/src/game.c @@ -1,13 +1,12 @@ /*********************************************************** * Rocks'n'Diamonds -- McDuffin Strikes Back! * *----------------------------------------------------------* -* ©1995 Artsoft Development * -* Holger Schemel * -* 33659 Bielefeld-Senne * -* Telefon: (0521) 493245 * -* eMail: aeglos@valinor.owl.de * -* aeglos@uni-paderborn.de * -* q99492@pbhrzx.uni-paderborn.de * +* (c) 1995-98 Artsoft Entertainment * +* Holger Schemel * +* Oststrasse 11a * +* 33604 Bielefeld * +* phone: ++49 +521 290471 * +* email: aeglos@valinor.owl.de * *----------------------------------------------------------* * game.c * ***********************************************************/ @@ -114,7 +113,11 @@ void InitGame() /* TEST TEST TEST */ + + /* stored_player[i].active = TRUE; + */ + /* TEST TEST TEST */ player->LevelSolved = FALSE; @@ -130,7 +133,10 @@ void InitGame() FrameCounter = 0; TimeFrames = 0; TimeLeft = level.time; + + ScreenMovDir = MV_NO_MOVING; ScreenMovPos = 0; + ScreenGfxPos = 0; AllPlayersGone = SiebAktiv = FALSE; @@ -168,6 +174,8 @@ void InitGame() if (StorePlayer[jx][jy] == Feld[x][y]) StorePlayer[jx][jy] = 0; + player->active = TRUE; + StorePlayer[x][y] = Feld[x][y]; Feld[x][y] = EL_LEERRAUM; player->jx = player->last_jx = x; @@ -601,6 +609,14 @@ int MovingOrBlocked2Element(int x, int y) return(element); } +static void RemoveField(int x, int y) +{ + Feld[x][y] = EL_LEERRAUM; + MovPos[x][y] = 0; + MovDir[x][y] = 0; + MovDelay[x][y] = 0; +} + void RemoveMovingField(int x, int y) { int oldx = x,oldy = y, newx = x,newy = y; @@ -643,7 +659,7 @@ void RemoveMovingField(int x, int y) void DrawDynamite(int x, int y) { - int sx = SCROLLX(x), sy = SCROLLY(y); + int sx = SCREENX(x), sy = SCREENY(y); int graphic = el2gfx(Feld[x][y]); int phase; @@ -836,12 +852,12 @@ void Explode(int ex, int ey, int phase, int mode) InitMovDir(x,y); DrawLevelField(x,y); } - else if (!(phase%delay) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y))) + else if (!(phase%delay) && IN_SCR_FIELD(SCREENX(x),SCREENY(y))) { if (phase==delay) - ErdreichAnbroeckeln(SCROLLX(x),SCROLLY(y)); + ErdreichAnbroeckeln(SCREENX(x),SCREENY(y)); - DrawGraphic(SCROLLX(x),SCROLLY(y),GFX_EXPLOSION+(phase/delay-1)); + DrawGraphic(SCREENX(x),SCREENY(y),GFX_EXPLOSION+(phase/delay-1)); } } @@ -951,8 +967,8 @@ void Blurb(int x, int y) if (MovDelay[x][y]) /* neue Phase / in Wartezustand */ { MovDelay[x][y]--; - if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y))) - DrawGraphic(SCROLLX(x),SCROLLY(y),graphic+4-MovDelay[x][y]/2); + if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x),SCREENY(y))) + DrawGraphic(SCREENX(x),SCREENY(y),graphic+4-MovDelay[x][y]/2); if (!MovDelay[x][y]) { @@ -1490,6 +1506,28 @@ void TurnRound(int x, int y) } } +static BOOL JustBeingPushed(int x, int y) +{ + int i; + + for(i=0; iactive && !player->gone && + player->Pushing && player->MovPos) + { + int next_jx = player->jx + (player->jx - player->last_jx); + int next_jy = player->jy + (player->jy - player->last_jy); + + if (x == next_jx && y == next_jy) + return(TRUE); + } + } + + return(FALSE); +} + void StartMoving(int x, int y) { int element = Feld[x][y]; @@ -1499,26 +1537,9 @@ void StartMoving(int x, int y) if (CAN_FALL(element) && y0 && IS_PLAYER(x-1,y)) || (xactive && !player->gone && - player->Pushing && player->MovPos) - { - int next_jx = player->jx + (player->jx - player->last_jx); - int next_jy = player->jy + (player->jy - player->last_jy); - - if (x == next_jx && y == next_jy) - return; - } - } - } + if (JustBeingPushed(x,y)) + return; if (element==EL_MORAST_VOLL) { @@ -1648,6 +1669,9 @@ void StartMoving(int x, int y) { int newx,newy; + if (element == EL_SONDE && JustBeingPushed(x,y)) + return; + if (!MovDelay[x][y]) /* neuer Schritt / noch nicht gewartet */ { /* Alle Figuren, die nach jeden Schritt die Richtung wechseln können. @@ -1673,8 +1697,8 @@ void StartMoving(int x, int y) if (phase>3) phase = 7-phase; - if (IN_SCR_FIELD(SCROLLX(x),SCROLLY(y))) - DrawGraphic(SCROLLX(x),SCROLLY(y), el2gfx(element)+phase); + if (IN_SCR_FIELD(SCREENX(x),SCREENY(y))) + DrawGraphic(SCREENX(x),SCREENY(y), el2gfx(element)+phase); if ((element==EL_MAMPFER || element==EL_MAMPFER2) && MovDelay[x][y]%4==3) @@ -1695,7 +1719,7 @@ void StartMoving(int x, int y) for(i=1;i<=3;i++) { int xx = x + i*dx, yy = y + i*dy; - int sx = SCROLLX(xx), sy = SCROLLY(yy); + int sx = SCREENX(xx), sy = SCREENY(yy); if (!IN_LEV_FIELD(xx,yy) || IS_SOLID(Feld[xx][yy]) || Feld[xx][yy]==EL_EXPLODING) @@ -1764,8 +1788,8 @@ void StartMoving(int x, int y) DrawLevelField(x,y); PlaySoundLevel(newx,newy,SND_BUING); - if (IN_SCR_FIELD(SCROLLX(newx),SCROLLY(newy))) - DrawGraphicThruMask(SCROLLX(newx),SCROLLY(newy),el2gfx(element)); + if (IN_SCR_FIELD(SCREENX(newx),SCREENY(newy))) + DrawGraphicThruMask(SCREENX(newx),SCREENY(newy),el2gfx(element)); local_player->friends_still_needed--; if (!local_player->friends_still_needed && @@ -1902,27 +1926,7 @@ void StartMoving(int x, int y) else if (element == EL_BUTTERFLY || element == EL_FIREFLY) DrawGraphicAnimation(x,y, el2gfx(element), 2, 4, ANIM_NORMAL); else if (element==EL_SONDE) - { - int i; - - /* check if this element is just being pushed */ - for(i=0; iactive && !player->gone && - player->Pushing && player->GfxPos) - { - int next_jx = player->jx + (player->jx - player->last_jx); - int next_jy = player->jy + (player->jy - player->last_jy); - - if (x == next_jx && y == next_jy) - return; - } - } - DrawGraphicAnimation(x,y, GFX_SONDE_START, 8, 2, ANIM_NORMAL); - } return; } @@ -2186,8 +2190,8 @@ void AmoebeWaechst(int x, int y) if (MovDelay[x][y]) /* neue Phase / in Wartezustand */ { MovDelay[x][y]--; - if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y))) - DrawGraphic(SCROLLX(x),SCROLLY(y),GFX_AMOEBING+3-MovDelay[x][y]/2); + if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x),SCREENY(y))) + DrawGraphic(SCREENX(x),SCREENY(y),GFX_AMOEBING+3-MovDelay[x][y]/2); if (!MovDelay[x][y]) { @@ -2402,8 +2406,8 @@ void Ablenk(int x, int y) MovDelay[x][y]--; if (MovDelay[x][y]) { - if (IN_SCR_FIELD(SCROLLX(x),SCROLLY(y))) - DrawGraphic(SCROLLX(x),SCROLLY(y),GFX_ABLENK+MovDelay[x][y]%4); + if (IN_SCR_FIELD(SCREENX(x),SCREENY(y))) + DrawGraphic(SCREENX(x),SCREENY(y),GFX_ABLENK+MovDelay[x][y]%4); if (!(MovDelay[x][y]%4)) PlaySoundLevel(x,y,SND_MIEP); return; @@ -2461,8 +2465,8 @@ void NussKnacken(int x, int y) if (MovDelay[x][y]) /* neue Phase / in Wartezustand */ { MovDelay[x][y]--; - if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y))) - DrawGraphic(SCROLLX(x),SCROLLY(y),GFX_CRACKINGNUT+3-MovDelay[x][y]/2); + if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x),SCREENY(y))) + DrawGraphic(SCREENX(x),SCREENY(y),GFX_CRACKINGNUT+3-MovDelay[x][y]/2); if (!MovDelay[x][y]) { @@ -2474,8 +2478,8 @@ void NussKnacken(int x, int y) void SiebAktivieren(int x, int y, int typ) { - if (!(SiebAktiv % 4) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y))) - DrawGraphic(SCROLLX(x),SCROLLY(y), + if (!(SiebAktiv % 4) && IN_SCR_FIELD(SCREENX(x),SCREENY(y))) + DrawGraphic(SCREENX(x),SCREENY(y), (typ==1 ? GFX_SIEB_VOLL : GFX_SIEB2_VOLL)+3-(SiebAktiv%16)/4); } @@ -2487,10 +2491,10 @@ void AusgangstuerPruefen(int x, int y) { Feld[x][y] = EL_AUSGANG_ACT; - PlaySoundLevel(x < UNSCROLLX(BX1) ? UNSCROLLX(BX1) : - (x > UNSCROLLX(BX2) ? UNSCROLLX(BX2) : x), - y < UNSCROLLY(BY1) ? UNSCROLLY(BY1) : - (y > UNSCROLLY(BY2) ? UNSCROLLY(BY2) : y), + PlaySoundLevel(x < LEVELX(BX1) ? LEVELX(BX1) : + (x > LEVELX(BX2) ? LEVELX(BX2) : x), + y < LEVELY(BY1) ? LEVELY(BY1) : + (y > LEVELY(BY2) ? LEVELY(BY2) : y), SND_OEFFNEN); } } @@ -2508,8 +2512,8 @@ void AusgangstuerOeffnen(int x, int y) MovDelay[x][y]--; tuer = MovDelay[x][y]/delay; - if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y))) - DrawGraphic(SCROLLX(x),SCROLLY(y),GFX_AUSGANG_AUF-tuer); + if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCREENX(x),SCREENY(y))) + DrawGraphic(SCREENX(x),SCREENY(y),GFX_AUSGANG_AUF-tuer); if (!MovDelay[x][y]) { @@ -2526,7 +2530,7 @@ void AusgangstuerBlinken(int x, int y) void EdelsteinFunkeln(int x, int y) { - if (!IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)) || IS_MOVING(x,y)) + if (!IN_SCR_FIELD(SCREENX(x),SCREENY(y)) || IS_MOVING(x,y)) return; if (Feld[x][y] == EL_EDELSTEIN_BD) @@ -2543,7 +2547,7 @@ void EdelsteinFunkeln(int x, int y) if (direct_draw_on && MovDelay[x][y]) SetDrawtoField(DRAW_BUFFERED); - DrawGraphic(SCROLLX(x),SCROLLY(y), el2gfx(Feld[x][y])); + DrawGraphic(SCREENX(x),SCREENY(y), el2gfx(Feld[x][y])); if (MovDelay[x][y]) { @@ -2552,14 +2556,14 @@ void EdelsteinFunkeln(int x, int y) if (phase > 2) phase = 4-phase; - DrawGraphicThruMask(SCROLLX(x),SCROLLY(y), GFX_FUNKELN_WEISS + phase); + DrawGraphicThruMask(SCREENX(x),SCREENY(y), GFX_FUNKELN_WEISS + phase); if (direct_draw_on) { int dest_x,dest_y; - dest_x = FX + SCROLLX(x)*TILEX; - dest_y = FY + SCROLLY(y)*TILEY; + dest_x = FX + SCREENX(x)*TILEX; + dest_y = FY + SCREENY(y)*TILEY; XCopyArea(display,drawto_field,window,gc, dest_x,dest_y, TILEX,TILEY, dest_x,dest_y); @@ -2583,8 +2587,8 @@ void MauerWaechst(int x, int y) MovDelay[x][y]--; phase = 2-MovDelay[x][y]/delay; - if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y))) - DrawGraphic(SCROLLX(x),SCROLLY(y), + if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCREENX(x),SCREENY(y))) + DrawGraphic(SCREENX(x),SCREENY(y), (Store[x][y]==MV_LEFT ? GFX_MAUER_L1 : GFX_MAUER_R1)+phase); if (!MovDelay[x][y]) @@ -2631,15 +2635,15 @@ void MauerAbleger(int ax, int ay) { Feld[ax-1][ay] = EL_MAUERND; Store[ax-1][ay] = MV_LEFT; - if (IN_SCR_FIELD(SCROLLX(ax-1),SCROLLY(ay))) - DrawGraphic(SCROLLX(ax-1),SCROLLY(ay),GFX_MAUER_L1); + if (IN_SCR_FIELD(SCREENX(ax-1),SCREENY(ay))) + DrawGraphic(SCREENX(ax-1),SCREENY(ay),GFX_MAUER_L1); } if (rechts_frei) { Feld[ax+1][ay] = EL_MAUERND; Store[ax+1][ay] = MV_RIGHT; - if (IN_SCR_FIELD(SCROLLX(ax+1),SCROLLY(ay))) - DrawGraphic(SCROLLX(ax+1),SCROLLY(ay),GFX_MAUER_R1); + if (IN_SCR_FIELD(SCREENX(ax+1),SCREENY(ay))) + DrawGraphic(SCREENX(ax+1),SCREENY(ay),GFX_MAUER_R1); } if (links_frei || rechts_frei) @@ -2705,6 +2709,8 @@ void CheckForDragon(int x, int y) void PlayerActions(struct PlayerInfo *player, int player_action) { + static int stored_player_action[MAX_PLAYERS]; + static int num_stored_actions = 0; BOOL moved = FALSE, snapped = FALSE, bombed = FALSE; int jx = player->jx, jy = player->jy; int left = player_action & JOY_LEFT; @@ -2716,6 +2722,9 @@ void PlayerActions(struct PlayerInfo *player, int player_action) int dx = (left ? -1 : right ? 1 : 0); int dy = (up ? -1 : down ? 1 : 0); + stored_player_action[player->nr] = 0; + num_stored_actions++; + if (!player->active || player->gone) return; @@ -2736,7 +2745,15 @@ void PlayerActions(struct PlayerInfo *player, int player_action) { if (bombed && !moved) player_action &= JOY_BUTTON; - TapeRecordAction(player_action); + + stored_player_action[player->nr] = player_action; + + /* this allows cycled sequences of PlayerActions() */ + if (num_stored_actions >= MAX_PLAYERS) + { + TapeRecordAction(stored_player_action); + num_stored_actions = 0; + } } else if (tape.playing && snapped) SnapField(player, 0,0); /* stop snapping */ @@ -2752,7 +2769,8 @@ void PlayerActions(struct PlayerInfo *player, int player_action) if (tape.playing && !tape.pausing && !player_action && tape.counter < tape.length) { - int next_joy = tape.pos[tape.counter].joystickdata & (JOY_LEFT|JOY_RIGHT); + int next_joy = + tape.pos[tape.counter].joystickdata[player->nr] & (JOY_LEFT|JOY_RIGHT); if (next_joy == JOY_LEFT || next_joy == JOY_RIGHT) { @@ -2780,6 +2798,7 @@ void GameActions(int player_action) long action_delay_value; int sieb_x = 0, sieb_y = 0; int i, x,y, element; + int *recorded_player_action; if (game_status != PLAYING) return; @@ -2795,12 +2814,30 @@ void GameActions(int player_action) /* main game synchronization point */ WaitUntilDelayReached(&action_delay, action_delay_value); + if (tape.playing) + recorded_player_action = TapePlayAction(); + else + recorded_player_action = NULL; + for(i=0; iGfxPos; + /* + ScreenGfxPos = local_player->GfxPos; + */ XCopyArea(display,drawto_field,drawto_field,gc, FX + TILEX*(dx==-1) - softscroll_offset, @@ -3001,6 +3080,9 @@ BOOL MoveFigureOneStep(struct PlayerInfo *player, 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)) @@ -3024,7 +3106,7 @@ BOOL MoveFigureOneStep(struct PlayerInfo *player, if (can_move != MF_MOVING) return(can_move); - StorePlayer[jx][jy] = EL_LEERRAUM; + StorePlayer[jx][jy] = 0; player->last_jx = jx; player->last_jy = jy; jx = player->jx = new_jx; @@ -3033,7 +3115,7 @@ BOOL MoveFigureOneStep(struct PlayerInfo *player, player->MovPos = (dx > 0 || dy > 0 ? -1 : 1) * 7*TILEX/8; - ScrollFigure(player, SCROLL_FIGURE_INIT); + ScrollFigure(player, SCROLL_INIT); return(MF_MOVING); } @@ -3064,20 +3146,93 @@ BOOL MoveFigure(struct PlayerInfo *player, int dx, int dy) 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) @@ -3115,11 +3270,15 @@ void ScrollFigure(struct PlayerInfo *player, int mode) 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; @@ -3132,11 +3291,21 @@ void ScrollFigure(struct PlayerInfo *player, int mode) 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; @@ -3147,7 +3316,46 @@ void ScrollFigure(struct PlayerInfo *player, int mode) { player->last_jx = jx; player->last_jy = jy; + + if (Feld[jx][jy] == EL_AUSGANG_AUF) + { + RemoveHero(player); + + if (!local_player->friends_still_needed) + player->LevelSolved = player->GameOver = TRUE; + } + } +} + +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) @@ -3394,23 +3602,12 @@ int DigField(struct PlayerInfo *player, case EL_EDELSTEIN_GELB: case EL_EDELSTEIN_ROT: case EL_EDELSTEIN_LILA: - Feld[x][y] = EL_LEERRAUM; - MovDelay[x][y] = 0; /* wegen EDELSTEIN_BD-Funkeln! */ - if (local_player->gems_still_needed > 0) - local_player->gems_still_needed--; - RaiseScoreElement(EL_EDELSTEIN); - DrawText(DX_EMERALDS, DY_EMERALDS, - int2str(local_player->gems_still_needed, 3), - FS_SMALL, FC_YELLOW); - PlaySoundLevel(x, y, SND_PONG); - break; - case EL_DIAMANT: - Feld[x][y] = EL_LEERRAUM; - local_player->gems_still_needed -= 3; + RemoveField(x,y); + local_player->gems_still_needed -= (element == EL_DIAMANT ? 3 : 1); if (local_player->gems_still_needed < 0) local_player->gems_still_needed = 0; - RaiseScoreElement(EL_DIAMANT); + RaiseScoreElement(element); DrawText(DX_EMERALDS, DY_EMERALDS, int2str(local_player->gems_still_needed, 3), FS_SMALL, FC_YELLOW); @@ -3418,7 +3615,7 @@ int DigField(struct PlayerInfo *player, break; case EL_DYNAMIT_AUS: - Feld[x][y] = EL_LEERRAUM; + RemoveField(x,y); player->dynamite++; RaiseScoreElement(EL_DYNAMIT); DrawText(DX_DYNAMITE, DY_DYNAMITE, @@ -3428,22 +3625,22 @@ int DigField(struct PlayerInfo *player, break; case EL_DYNABOMB_NR: - Feld[x][y] = EL_LEERRAUM; + RemoveField(x,y); player->dynabomb_count++; player->dynabombs_left++; RaiseScoreElement(EL_DYNAMIT); PlaySoundLevel(x,y,SND_PONG); break; - case EL_DYNABOMB_SZ: - Feld[x][y] = EL_LEERRAUM; + case EL_DYNABOMB_SZ: + RemoveField(x,y); player->dynabomb_size++; RaiseScoreElement(EL_DYNAMIT); PlaySoundLevel(x,y,SND_PONG); break; case EL_DYNABOMB_XL: - Feld[x][y] = EL_LEERRAUM; + RemoveField(x,y); player->dynabomb_xl = TRUE; RaiseScoreElement(EL_DYNAMIT); PlaySoundLevel(x,y,SND_PONG); @@ -3456,7 +3653,7 @@ int DigField(struct PlayerInfo *player, { int key_nr = element-EL_SCHLUESSEL1; - Feld[x][y] = EL_LEERRAUM; + RemoveField(x,y); player->key[key_nr] = TRUE; RaiseScoreElement(EL_SCHLUESSEL); DrawMiniGraphicExt(drawto,gc, @@ -3501,7 +3698,7 @@ int DigField(struct PlayerInfo *player, !tape.playing) return(MF_NO_ACTION); - Feld[x][y] = EL_LEERRAUM; + RemoveField(x,y); Feld[x+dx][y+dy] = element; player->push_delay_value = 2+RND(8); @@ -3541,11 +3738,15 @@ int DigField(struct PlayerInfo *player, if (mode==DF_SNAP) return(MF_NO_ACTION); + PlaySoundLevel(x,y,SND_BUING); + + /* player->gone = TRUE; PlaySoundLevel(x,y,SND_BUING); if (!local_player->friends_still_needed) player->LevelSolved = player->GameOver = TRUE; + */ break; @@ -3608,7 +3809,7 @@ int DigField(struct PlayerInfo *player, local_player->sokobanfields_still_needed++; } else - Feld[x][y] = EL_LEERRAUM; + RemoveField(x,y); if (Feld[x+dx][y+dy] == EL_SOKOBAN_FELD_LEER) { @@ -3622,7 +3823,7 @@ int DigField(struct PlayerInfo *player, } else { - Feld[x][y] = EL_LEERRAUM; + RemoveField(x,y); Feld[x+dx][y+dy] = element; } @@ -3717,7 +3918,7 @@ BOOL PlaceBomb(struct PlayerInfo *player) player->dynamite--; DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(local_player->dynamite, 3), FS_SMALL, FC_YELLOW); - DrawGraphicThruMask(SCROLLX(jx),SCROLLY(jy),GFX_DYNAMIT); + DrawGraphicThruMask(SCREENX(jx),SCREENY(jy),GFX_DYNAMIT); } else { @@ -3725,7 +3926,7 @@ BOOL PlaceBomb(struct PlayerInfo *player) Store2[jx][jy] = EL_SPIELER1 + player->nr; /* for DynaExplode() */ MovDelay[jx][jy] = 96; player->dynabombs_left--; - DrawGraphicThruMask(SCROLLX(jx),SCROLLY(jy),GFX_DYNABOMB); + DrawGraphicThruMask(SCREENX(jx),SCREENY(jy),GFX_DYNABOMB); } return(TRUE); @@ -3733,7 +3934,7 @@ BOOL PlaceBomb(struct PlayerInfo *player) void PlaySoundLevel(int x, int y, int sound_nr) { - int sx = SCROLLX(x), sy = SCROLLY(y); + int sx = SCREENX(x), sy = SCREENY(y); int volume, stereo; int silence_distance = 8; @@ -3778,6 +3979,10 @@ void RaiseScoreElement(int element) switch(element) { case EL_EDELSTEIN: + case EL_EDELSTEIN_BD: + case EL_EDELSTEIN_GELB: + case EL_EDELSTEIN_ROT: + case EL_EDELSTEIN_LILA: RaiseScore(level.score[SC_EDELSTEIN]); break; case EL_DIAMANT: