예제 #1
0
파일: game.c 프로젝트: uli/xrick-spmp8000
void
game_toggleCheat(U8 nbr)
{
  if (game_state != INTRO_MAIN && game_state != INTRO_MAP &&
      game_state != GAMEOVER && game_state != GETNAME &&
#ifdef ENABLE_DEVTOOLS
      game_state != DEVTOOLS &&
#endif
      game_state != XRICK && game_state != EXIT) {
    switch (nbr) {
    case 1:
      game_cheat1 = ~game_cheat1;
      game_lives = 6;
      game_bombs = 6;
      game_bullets = 6;
      break;
    case 2:
      game_cheat2 = ~game_cheat2;
      break;
    case 3:
      game_cheat3 = ~game_cheat3;
      break;
    }
    draw_infos();
    /* FIXME this should probably only raise a flag ... */
    /* plus we only need to update INFORECT not the whole screen */
    sysvid_update(&draw_SCREENRECT);
  }
}
예제 #2
0
파일: game.c 프로젝트: HerbFargus/xrick
/*
 * Main loop
 */
void
game_run(void)
{
  U32 tm, tmx;

	loaddata(); /* load cached data */

	game_period = sysarg_args_period ? sysarg_args_period : GAME_PERIOD;
	tm = sys_gettime();
	game_state = XRICK;

	/* main loop */
	while (game_state != EXIT) {

		/* timer */
		tmx = tm; tm = sys_gettime(); tmx = tm - tmx;
		if (tmx < game_period) sys_sleep(game_period - tmx);

		/* video */
		/*DEBUG*//*game_rects=&draw_SCREENRECT;*//*DEBUG*/
		sysvid_update(game_rects);
		draw_STATUSRECT.next = NULL;  /* FIXME freerects should handle this */

		/* sound */
		/*snd_mix();*/

		/* events */
		if (game_waitevt)
			sysevt_wait();  /* wait for an event */
		else
			sysevt_poll();  /* process events (non-blocking) */

		/* frame */
		frame();
	}

	freedata(); /* free cached data */
}
예제 #3
0
파일: game.c 프로젝트: uli/xrick-spmp8000
/*
 * Main loop
 */
void
game_run(void)
{
  U32 tm;
#if 0
  U32 tmx;
#endif

	loaddata(); /* load cached data */

	game_period = sysarg_args_period ? sysarg_args_period : GAME_PERIOD;
	tm = sys_gettime();
	game_state = XRICK;

	/* main loop */
	while (game_state != EXIT) {

#if 0
		/* This code doesn't make any sense to me at all. It waits
		   until the desired amount of time has passed and then
		   takes the time at which it started waiting (which is
		   not synchronous with anything) as the reference point
		   for the next frame. This sort of works if your system
		   takes very little time to compute the frame, but fails
		   horribly otherwise, e.g. if you use blocking I/O
		   (sound, vblank). */
		tmx = tm; tm = sys_gettime(); tmx = tm - tmx;
		if (tmx < game_period) sys_sleep(game_period - tmx);
#endif

		/* video */
		/*DEBUG*//*game_rects=&draw_SCREENRECT;*//*DEBUG*/
		sysvid_update(game_rects);
		draw_STATUSRECT.next = NULL;  /* FIXME freerects should handle this */

		/* timer */
		/* Reset the timing if it's way out of line, such as when
		   the game thread has been paused. */
		if (sys_gettime() - tm > game_period * 10)
			tm = sys_gettime() - game_period / 2;
		/* Update sound while waiting. */
		do {
			syssnd_callback();
		} while (sys_gettime() - tm < game_period / 2);
		/* Use the time at which the frame should have been complete as
		   reference for the next frame. This makes it possible to
		   "catch up" if a frame has taken longer for some reason. */
		tm = tm + game_period / 2;

		/* sound */
		/*snd_mix();*/

		/* events */
		if (game_waitevt)
			sysevt_wait();  /* wait for an event */
		else
			sysevt_poll();  /* process events (non-blocking) */

		/* frame */
		frame();
	}

	freedata(); /* free cached data */
}