X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=c669e5e7b5d24f189f297768a4c1c116515b31d8;hb=4b0c6356359ee52f98cee8fa578179c6c41d4ef1;hp=edce9a9c4ac35ae3a8026938199847e2e3f24c10;hpb=4b0f1eb4220d2dbe4cffb288f745661b32c96a5b;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index edce9a9c..c669e5e7 100644 --- a/src/events.c +++ b/src/events.c @@ -65,12 +65,18 @@ void EventLoop(void) else /* got no event, but don't be lazy... */ { HandleNoXEvent(); - Delay(1000); /* don't use all CPU time when idle */ - } - XSync(display,FALSE); + /* don't use all CPU time when idle; the main loop while playing + has its own synchronization and is CPU friendly, too */ + + if (game_status != PLAYING) + { + XSync(display, FALSE); + Delay(10000); + } + } - if (game_status==EXITGAME) + if (game_status == EXITGAME) return; } } @@ -170,10 +176,17 @@ void HandleExposeEvent(XExposeEvent *event) SetDrawtoField(DRAW_DIRECT); } - if (soft_scrolling_on && game_status==PLAYING) + if (soft_scrolling_on && game_status == PLAYING) + { + int fx = FX, fy = FY; + + fx += (PlayerMovDir & (MV_LEFT|MV_RIGHT) ? ScreenMovPos : 0); + fy += (PlayerMovDir & (MV_UP|MV_DOWN) ? ScreenMovPos : 0); + XCopyArea(display,fieldbuffer,backbuffer,gc, - FX,FY, SXSIZE,SYSIZE, + fx,fy, SXSIZE,SYSIZE, SX,SY); + } XCopyArea(display,drawto,window,gc, x,y, width,height, x,y); @@ -285,9 +298,6 @@ void HandleButton(int mx, int my, int button) } } -int GameSpeed = 2; -int MoveSpeed = 8; - void HandleKey(KeySym key, int key_status) { int joy = 0; @@ -612,29 +622,6 @@ void HandleKey(KeySym key, int key_status) Delay(1000000); } - break; - - case XK_z: - { - static int test_picture_pos = 0; - - printf("test picture %d\n", test_picture_pos); - - XCopyArea(display,test_pix[test_picture_pos],window,gc, - 0,0, 100,100, - 0,0); - /* - XCopyArea(display,test_clipmask[test_picture_pos],window,gc, - 0,0, 100,100, - 100,0); - */ - XFlush(display); - XSync(display,FALSE); - Delay(1000000); - - test_picture_pos = (test_picture_pos + 1) % test_picture_count; - } - break; #endif @@ -720,6 +707,7 @@ void HandleJoystick() break; case PLAYING: { + static int player_frame_reset_delay = 0; BOOL moved = FALSE, snapped = FALSE, bombed = FALSE; if (GameOver && newbutton) @@ -735,6 +723,8 @@ void HandleJoystick() if (joy) { + player_frame_reset_delay = 0; + if (button1) snapped = SnapField(dx,dy); else @@ -757,7 +747,8 @@ void HandleJoystick() { DigField(0,0,0,0,DF_NO_PUSH); SnapField(0,0); - PlayerFrame = 0; + if (++player_frame_reset_delay > MoveSpeed) + PlayerFrame = 0; } if (tape.playing && !tape.pausing && !joy && tape.counter