X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=2ed2996640d37d969c134f6d6975ecb351eddf72;hb=19e3dfa321d39a822bda8fa489fb76f25f9f9165;hp=521cc1a8e549fcb3889e1ad86a6f055005d3bec5;hpb=5335fd9e893a7af87a72fb78609c2eb281bd7f63;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 521cc1a8..2ed29966 100644 --- a/src/game.c +++ b/src/game.c @@ -23,9 +23,15 @@ #include "tape.h" #include "joystick.h" -extern int Gamespeed; -extern int Movemethod; -extern int Movespeed[2]; + + +int tst = 0; +int tst2 = 0; + + + +extern int GameSpeed; +extern int MoveSpeed; void GetPlayerConfig() { @@ -78,6 +84,7 @@ void InitGame() ScreenMovPos = 0; PlayerMovDir = MV_NO_MOVING; PlayerMovPos = 0; + PlayerGfxPos = 0; PlayerFrame = 0; PlayerPushing = FALSE; PlayerGone = LevelSolved = GameOver = SiebAktiv = FALSE; @@ -107,8 +114,8 @@ void InitGame() case EL_SPIELFIGUR: case EL_SPIELER1: Feld[x][y] = EL_LEERRAUM; - JX = x; - JY = y; + JX = lastJX = x; + JY = lastJY = y; break; case EL_SPIELER2: Feld[x][y] = EL_LEERRAUM; @@ -1392,6 +1399,15 @@ void StartMoving(int x, int y) if (CAN_FALL(element) && y %ld / %ld [%d]\n", + new_Counter - last_Counter, + new_Counter, + FrameCounter); + last_Counter = new_Counter; + } + + + + + /* if (!DelayReached(&action_delay, action_delay_value)) return; + */ + + + while(!DelayReached(&action_delay, action_delay_value)) + Delay(1000); + + + + + /* + printf("-----------\n"); + */ + + + + FrameCounter++; + + + + /* + if (PlayerMovPos) + ScrollFigure(0); + + DrawPlayerField(); + */ + + + tst2 = tst; + tst = 0; + + + + if (0) + { + static long last_Counter = 0; + long new_Counter = Counter(); + + printf("--> %ld / %ld [%d]\n", + new_Counter - last_Counter, + new_Counter, + FrameCounter); + last_Counter = new_Counter; + } + + + /* + printf("--> %ld / ", Counter()); + */ + { int x,y,element; @@ -2593,7 +2680,12 @@ void GameActions() else if (tape.recording) TapeRecordDelay(); + + /* FrameCounter++; + */ + + TimeFrames++; for(y=0;y0 && TimeFrames>=25 && !tape.pausing) + if (TimeLeft>0 && TimeFrames>=(100/GameSpeed) && !tape.pausing) { TimeFrames = 0; TimeLeft--; @@ -2742,43 +2832,17 @@ void GameActions() KillHero(); } - /* - if (PlayerMovPos) - ScrollFigure(0); - */ - - - /* DrawPlayerField(); - */ - - - DrawPlayerField(); - BackToFront(); } void ScrollLevel(int dx, int dy) { + int softscroll_offset = (soft_scrolling_on ? TILEX : 0); int x,y; - int softscroll_offset = (FX == TILEX ? TILEX : 0); - - /* - if (soft_scrolling_on) - { - ScreenMovPos = PlayerMovPos; - redraw_mask |= REDRAW_FIELD; - } - */ - - - ScreenMovPos = PlayerMovPos; - if (soft_scrolling_on) - { - redraw_mask |= REDRAW_FIELD; - } + ScreenMovPos = PlayerGfxPos; XCopyArea(display,drawto_field,drawto_field,gc, FX + TILEX*(dx==-1) - softscroll_offset, @@ -2806,14 +2870,10 @@ void ScrollLevel(int dx, int dy) BOOL MoveFigureOneStep(int dx, int dy, int real_dx, int real_dy) { - int oldJX,oldJY, newJX = JX+dx,newJY = JY+dy; + int newJX = JX+dx, newJY = JY+dy; int element; int can_move; -/* - int old_move_dir = PlayerMovDir; -*/ - if (PlayerGone || (!dx && !dy)) return(MF_NO_ACTION); @@ -2821,12 +2881,6 @@ BOOL MoveFigureOneStep(int dx, int dy, int real_dx, int real_dy) dx > 0 ? MV_RIGHT : dy < 0 ? MV_UP : dy > 0 ? MV_DOWN : MV_NO_MOVING); -/* - if (old_move_dir != PlayerMovDir) - PlayerFrame = 0; - else - PlayerFrame = (PlayerFrame + 1) % 4; -*/ if (!IN_LEV_FIELD(newJX,newJY)) return(MF_NO_ACTION); @@ -2854,30 +2908,15 @@ BOOL MoveFigureOneStep(int dx, int dy, int real_dx, int real_dy) if (can_move != MF_MOVING) return(can_move); - oldJX = JX; - oldJY = JY; + lastJX = JX; + lastJY = JY; JX = newJX; JY = newJY; - - lastJX = oldJX; - lastJY = oldJY; - - PlayerMovPos = (dx > 0 || dy > 0 ? -1 : 1) * 3*TILEX/4; + PlayerMovPos = (dx > 0 || dy > 0 ? -1 : 1) * 7*TILEX/8; ScrollFigure(-1); - if (Store[oldJX][oldJY]) - { - DrawGraphic(SCROLLX(oldJX),SCROLLY(oldJY),el2gfx(Store[oldJX][oldJY])); - DrawGraphicThruMask(SCROLLX(oldJX),SCROLLY(oldJY), - el2gfx(Feld[oldJX][oldJY])); - } - else if (Feld[oldJX][oldJY]==EL_DYNAMIT) - DrawDynamite(oldJX,oldJY); - else - DrawLevelField(oldJX,oldJY); - return(MF_MOVING); } @@ -2891,32 +2930,8 @@ BOOL MoveFigure(int dx, int dy) if (PlayerGone || (!dx && !dy)) return(FALSE); -/* - if (!DelayReached(&move_delay,8) && !tape.playing) + if (!FrameReached(&move_delay,MoveSpeed) && !tape.playing) return(FALSE); -*/ - -/* - if (!DelayReached(&move_delay,10) && !tape.playing) - return(FALSE); -*/ - -/* - if (!FrameReached(&move_delay,2) && !tape.playing) - return(FALSE); -*/ - - if (Movemethod == 0) - { - if (!DelayReached(&move_delay,Movespeed[0]) && !tape.playing) - return(FALSE); - } - else - { - if (!FrameReached(&move_delay,Movespeed[1]) && !tape.playing) - return(FALSE); - } - if (last_move_dir & (MV_LEFT | MV_RIGHT)) { @@ -2931,31 +2946,20 @@ BOOL MoveFigure(int dx, int dy) last_move_dir = MV_NO_MOVING; - - /* - if (moved |= MoveFigureOneStep(dx,0, dx,dy)) - moved |= MoveFigureOneStep(0,dy, dx,dy); - else - { - moved |= MoveFigureOneStep(0,dy, dx,dy); - moved |= MoveFigureOneStep(dx,0, dx,dy); - } - */ - if (moved & MF_MOVING) { - int old_scroll_x=scroll_x, old_scroll_y=scroll_y; + 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)) + 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)) + JY >= MIDPOSY-1-offset && JY <= lev_fieldy-(MIDPOSY-offset)) scroll_y = JY-MIDPOSY + (scroll_y < JY-MIDPOSY ? -offset : offset); - if (scroll_x!=old_scroll_x || scroll_y!=old_scroll_y) - ScrollLevel(old_scroll_x-scroll_x,old_scroll_y-scroll_y); + if (scroll_x != old_scroll_x || scroll_y != old_scroll_y) + ScrollLevel(old_scroll_x - scroll_x, old_scroll_y - scroll_y); } if (!(moved & MF_MOVING) && !PlayerPushing) @@ -2977,10 +2981,6 @@ BOOL MoveFigure(int dx, int dy) TestIfHeroHitsBadThing(); - /* - BackToFront(); - */ - if (PlayerGone) RemoveHero(); @@ -2989,35 +2989,39 @@ BOOL MoveFigure(int dx, int dy) void ScrollFigure(int init) { - static long actual_frame_counter; + static long actual_frame_counter = 0; static int oldJX = -1, oldJY = -1; if (init) { - /* - if (PlayerMovPos && oldJX != -1 && oldJY != -1) + + PlayerGfxPos = + (TILEX/ScrollSteps) * (PlayerMovPos / (TILEX/ScrollSteps)); + + + + if (0) { - if (Feld[lastJX][lastJY] == EL_LEERRAUM) - Feld[lastJX][lastJY] = EL_PLAYER_IS_LEAVING; - DrawLevelElement(oldJX,oldJY, Feld[oldJX][oldJY]); - DrawPlayerField(); + static long last_Counter = 0; + long new_Counter = Counter(); + + printf("--> %ld / %ld [%d, %d]\n", + new_Counter - last_Counter, + new_Counter, + FrameCounter, + tst2); + last_Counter = new_Counter; } - */ + + + if (oldJX != -1 && oldJY != -1) - { - /* - if (Feld[lastJX][lastJY] == EL_LEERRAUM) - Feld[lastJX][lastJY] = EL_PLAYER_IS_LEAVING; - */ DrawLevelElement(oldJX,oldJY, Feld[oldJX][oldJY]); - /* - DrawLevelElement(lastJX,lastJY, Feld[lastJX][lastJY]); - DrawPlayerField(); - */ - } - if (Feld[lastJX][lastJY] == EL_LEERRAUM) + if (Feld[lastJX][lastJY] == EL_LEERRAUM && + IN_LEV_FIELD(lastJX,lastJY-1) && + CAN_FALL(Feld[lastJX][lastJY-1])) Feld[lastJX][lastJY] = EL_PLAYER_IS_LEAVING; DrawLevelElement(lastJX,lastJY, Feld[lastJX][lastJY]); DrawPlayerField(); @@ -3026,27 +3030,45 @@ void ScrollFigure(int init) oldJY = lastJY; actual_frame_counter = FrameCounter; - /* - redraw[redraw_x1 + oldJX][redraw_y1 + oldJY] = 1; - redraw_tiles++; - */ + if (PlayerPushing) + { + int nextJX = JX + (JX - lastJX); + int nextJY = JY + (JY - lastJY); - /* - DrawLevelElement(oldJX,oldJY, Feld[oldJX][oldJY]); - */ + if (Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL) + DrawLevelElement(nextJX,nextJY, EL_SOKOBAN_FELD_LEER); + else + DrawLevelElement(nextJX,nextJY, EL_LEERRAUM); + } DrawPlayerField(); + if (Store[lastJX][lastJY]) + { + DrawGraphic(SCROLLX(lastJX),SCROLLY(lastJY), + el2gfx(Store[lastJX][lastJY])); + DrawGraphicThruMask(SCROLLX(lastJX),SCROLLY(lastJY), + el2gfx(Feld[lastJX][lastJY])); + } + else if (Feld[lastJX][lastJY]==EL_DYNAMIT) + DrawDynamite(lastJX,lastJY); + else + DrawLevelField(lastJX,lastJY); + return; } else if (!FrameReached(&actual_frame_counter,1)) return; - PlayerMovPos += (PlayerMovPos > 0 ? -1 : 1) * TILEX/4; + PlayerMovPos += (PlayerMovPos > 0 ? -1 : 1) * TILEX/8; + + + PlayerGfxPos = + (TILEX/ScrollSteps) * (PlayerMovPos / (TILEX/ScrollSteps)); if (ScreenMovPos) { - ScreenMovPos = PlayerMovPos; + ScreenMovPos = PlayerGfxPos; redraw_mask |= REDRAW_FIELD; } @@ -3069,7 +3091,21 @@ void ScrollFigure(int init) else DrawLevelField(oldJX,oldJY); + if (PlayerPushing) + { + int nextJX = JX + (JX - lastJX); + int nextJY = JY + (JY - lastJY); + if (PlayerGfxPos) + { + if (Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL) + DrawLevelElement(nextJX,nextJY, EL_SOKOBAN_FELD_LEER); + else + DrawLevelElement(nextJX,nextJY, EL_LEERRAUM); + } + else + DrawLevelElement(nextJX,nextJY, Feld[nextJX][nextJY]); + } if (!PlayerMovPos) { @@ -3268,7 +3304,8 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode) static long push_delay = 0; static int push_delay_value = 5; - PlayerPushing = FALSE; + if (!PlayerMovPos) + PlayerPushing = FALSE; if (mode == DF_NO_PUSH) {