From: Holger Schemel Date: Thu, 27 Aug 1998 01:37:28 +0000 (+0200) Subject: rnd-19980827 X-Git-Tag: 1.2.0^2~91 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=19e3dfa321d39a822bda8fa489fb76f25f9f9165;p=rocksndiamonds.git rnd-19980827 --- diff --git a/src/events.c b/src/events.c index 940fd379..b563a860 100644 --- a/src/events.c +++ b/src/events.c @@ -61,7 +61,7 @@ void EventLoop(void) else /* got no event, but don't be lazy... */ { HandleNoXEvent(); - Delay(10000); /* don't use all CPU time when idle */ + Delay(1000); /* don't use all CPU time when idle */ } XSync(display,FALSE); @@ -268,10 +268,8 @@ void HandleButton(int mx, int my, int button) } } -int Gamespeed = 4; -int Movemethod = 1; -int Movespeed[2] = { 10, 4 }; -char *Movespeed_text[2] = { "asynchron", "syncron" }; +int GameSpeed = 2; +int MoveSpeed = 8; void HandleKey(KeySym key, int key_status) { @@ -470,34 +468,41 @@ void HandleKey(KeySym key, int key_status) case XK_7: case XK_8: case XK_9: - Movespeed[Movemethod] = (Movemethod == 0 ? 4 : 0) + (key - XK_0); - printf("method == %d, speed == %d (%s)\n", - Movemethod, Movespeed[Movemethod], - Movespeed_text[Movemethod]); + /* + MoveSpeed = key - XK_0; + printf("speed == %d\n", MoveSpeed); + break; + */ + + if (key == XK_0) + GameSpeed = 50; + else + GameSpeed = key - XK_0; + printf("GameSpeed == %d\n", GameSpeed); break; case XK_a: - Movemethod = !Movemethod; - printf("method == %d, speed == %d (%s)\n", - Movemethod, Movespeed[Movemethod], - Movespeed_text[Movemethod]); + if (ScrollSteps == TILEX/4) + ScrollSteps = TILEX/8; + else + ScrollSteps = TILEX/4; break; case XK_f: - Gamespeed = 2; - printf("gamespeed == %d\n", Gamespeed); + GameSpeed = 2; + printf("GameSpeed == %d\n", GameSpeed); break; case XK_g: - Gamespeed = 3; - printf("gamespeed == %d\n", Gamespeed); + GameSpeed = 3; + printf("GameSpeed == %d\n", GameSpeed); break; case XK_h: - Gamespeed = 4; - printf("gamespeed == %d\n", Gamespeed); + GameSpeed = 4; + printf("GameSpeed == %d\n", GameSpeed); break; case XK_l: - Gamespeed = 50; - printf("gamespeed == %d\n", Gamespeed); + GameSpeed = 50; + printf("GameSpeed == %d\n", GameSpeed); break; case XK_Q: @@ -508,13 +513,13 @@ void HandleKey(KeySym key, int key_status) case XK_x: { - int i,j,k, num_steps = 16, step_size = TILEX / num_steps; + int i,j,k, num_steps = 8, step_size = TILEX / num_steps; static long scroll_delay=0; long scroll_delay_value = 4*4 / num_steps; printf("Scroll test\n"); - for(i=0;i<10;i++) + for(i=0;i<3;i++) { for(j=0;j %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; @@ -2606,7 +2680,12 @@ void GameActions() else if (tape.recording) TapeRecordDelay(); + + /* FrameCounter++; + */ + + TimeFrames++; for(y=0;y0 && TimeFrames>=25 && !tape.pausing) + + /* + printf("%ld\n", Counter()); + */ + + + if (TimeLeft>0 && TimeFrames>=(100/GameSpeed) && !tape.pausing) { TimeFrames = 0; TimeLeft--; @@ -2757,7 +2842,7 @@ void ScrollLevel(int dx, int dy) int softscroll_offset = (soft_scrolling_on ? TILEX : 0); int x,y; - ScreenMovPos = PlayerMovPos; + ScreenMovPos = PlayerGfxPos; XCopyArea(display,drawto_field,drawto_field,gc, FX + TILEX*(dx==-1) - softscroll_offset, @@ -2828,7 +2913,7 @@ BOOL MoveFigureOneStep(int dx, int dy, int real_dx, int real_dy) JX = newJX; JY = newJY; - PlayerMovPos = (dx > 0 || dy > 0 ? -1 : 1) * 3*TILEX/4; + PlayerMovPos = (dx > 0 || dy > 0 ? -1 : 1) * 7*TILEX/8; ScrollFigure(-1); @@ -2845,16 +2930,8 @@ BOOL MoveFigure(int dx, int dy) if (PlayerGone || (!dx && !dy)) 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 (!FrameReached(&move_delay,MoveSpeed) && !tape.playing) + return(FALSE); if (last_move_dir & (MV_LEFT | MV_RIGHT)) { @@ -2912,11 +2989,33 @@ 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) { + + PlayerGfxPos = + (TILEX/ScrollSteps) * (PlayerMovPos / (TILEX/ScrollSteps)); + + + + if (0) + { + 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) DrawLevelElement(oldJX,oldJY, Feld[oldJX][oldJY]); @@ -2961,11 +3060,15 @@ void ScrollFigure(int init) 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; } @@ -2993,7 +3096,7 @@ void ScrollFigure(int init) int nextJX = JX + (JX - lastJX); int nextJY = JY + (JY - lastJY); - if (PlayerMovPos) + if (PlayerGfxPos) { if (Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL) DrawLevelElement(nextJX,nextJY, EL_SOKOBAN_FELD_LEER); diff --git a/src/main.c b/src/main.c index bd5edbb8..4f178700 100644 --- a/src/main.c +++ b/src/main.c @@ -82,14 +82,15 @@ long Elementeigenschaften[MAX_ELEMENTS]; int level_nr, leveldir_nr, num_leveldirs; int lev_fieldx,lev_fieldy, scroll_x,scroll_y; -int FX = SX, FY = SY, ScreenMovPos = 0; +int FX = SX, FY = SY, ScreenMovPos = 0, ScrollSteps = TILEX/4; int BX1 = 0, BY1 = 0, BX2 = SCR_FIELDX-1, BY2 = SCR_FIELDY-1; int JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY; -int PlayerMovDir, PlayerMovPos, PlayerFrame, PlayerPushing; -int PlayerGone,LevelSolved,GameOver; -int FrameCounter,TimeFrames,TimeLeft,Score; -int Gems,SokobanFields,Lights,Friends; -int Dynamite,Key[4],MampferNr; +int PlayerMovDir, PlayerMovPos, PlayerPushing; +int PlayerFrame, PlayerGfxPos; +int PlayerGone, LevelSolved, GameOver; +int FrameCounter, TimeFrames, TimeLeft, Score; +int Gems, SokobanFields, Lights, Friends; +int Dynamite, Key[4], MampferNr; int DynaBombCount, DynaBombSize, DynaBombsLeft, DynaBombXL; int SiebAktiv; diff --git a/src/main.h b/src/main.h index 455037c2..92de9f79 100644 --- a/src/main.h +++ b/src/main.h @@ -306,10 +306,11 @@ extern long Elementeigenschaften[MAX_ELEMENTS]; extern int level_nr, leveldir_nr, num_leveldirs; extern int lev_fieldx,lev_fieldy, scroll_x,scroll_y; -extern int FX,FY, ScreenMovPos; +extern int FX,FY, ScreenMovPos, ScrollSteps; extern int BX1,BY1, BX2,BY2; extern int JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY; -extern int PlayerMovDir, PlayerMovPos, PlayerFrame, PlayerPushing; +extern int PlayerMovDir, PlayerMovPos, PlayerPushing; +extern int PlayerFrame, PlayerGfxPos; extern int PlayerGone,LevelSolved,GameOver; extern int FrameCounter,TimeFrames,TimeLeft,Score; extern int Gems,SokobanFields,Lights,Friends; diff --git a/src/tools.c b/src/tools.c index 35adb435..a17288a1 100644 --- a/src/tools.c +++ b/src/tools.c @@ -101,15 +101,6 @@ void BackToFront() XCopyArea(display,buffer,window,gc, fx,fy, SXSIZE,SYSIZE, SX,SY); - - - - printf("Full screen redraw (%d) (%ld)\n", - ScreenMovPos, - Counter()); - - - } redraw_mask &= ~REDRAW_MAIN; } @@ -402,12 +393,12 @@ void DrawPlayerField() graphic += PlayerFrame; - if (PlayerMovPos) + if (PlayerGfxPos) { if (PlayerMovDir == MV_LEFT || PlayerMovDir == MV_RIGHT) - sxx = PlayerMovPos; + sxx = PlayerGfxPos; else - syy = PlayerMovPos; + syy = PlayerGfxPos; } @@ -433,7 +424,7 @@ void DrawPlayerField() - if (PlayerPushing && PlayerMovPos) + if (PlayerPushing && PlayerGfxPos) { int nextJX = JX + (JX - lastJX); int nextJY = JY + (JY - lastJY); @@ -451,7 +442,7 @@ void DrawPlayerField() if (element == EL_FELSBROCKEN && sxx) { - int phase = PlayerMovPos / (TILEX/4); + int phase = PlayerGfxPos / (TILEX/4); if (PlayerMovDir == MV_LEFT) graphic += phase;