Пример #1
0
void ram(void) {
	while(1) {
		if (!screen_intro()){
      setTextColor(0xff,0x00);
      return;
    }
		game.rokets = 3;
		game.level = 1;
		game.score = 0;
		init_game();
		screen_level();
		while (game.rokets>=0) {
			////checkISP();
			lcdFill(0x00);
			check_end();
			move_ufo();
			move_shot();
			move_shots();
			move_player();
			move_enemy();
			draw_score();
			draw_ufo();
			draw_bunker();
			draw_player();
			draw_enemy();
			draw_shots();
			//        draw_status();
			lcdDisplay();
			delayms(12);
		}
		if (!screen_gameover())
      setTextColor(0xff,0x00);
      return;
	}
}
Пример #2
0
/*
 * Prepare frame
 *
 * This function loops forever: use 'return' when a frame is ready.
 * When returning, game_rects must contain every parts of the buffer
 * that have been modified.
 */
static void
frame(void)
{
	while (1) {

		switch (game_state) {



#ifdef ENABLE_DEVTOOLS
		case DEVTOOLS:
			switch (devtools_run()) {
			case SCREEN_RUNNING:
				return;
			case SCREEN_DONE:
				game_state = INIT_GAME;
				break;
			case SCREEN_EXIT:
				game_state = EXIT;
				return;
			}
		break;
#endif



		case XRICK:
			switch(screen_xrick()) {
			case SCREEN_RUNNING:
				return;
			case SCREEN_DONE:
#ifdef ENABLE_DEVTOOLS
				game_state = DEVTOOLS;
#else
				game_state = INIT_GAME;
#endif
				break;
			case SCREEN_EXIT:
				game_state = EXIT;
				return;
			}
		break;



		case INIT_GAME:
			init();
			game_state = INTRO_MAIN;
			break;



		case INTRO_MAIN:
			switch (screen_introMain()) {
			case SCREEN_RUNNING:
				return;
			case SCREEN_DONE:
				game_state = INTRO_MAP;
				break;
			case SCREEN_EXIT:
				game_state = EXIT;
				return;
			}
		break;



		case INTRO_MAP:
			switch (screen_introMap()) {
			case SCREEN_RUNNING:
				return;
			case SCREEN_DONE:
				game_waitevt = FALSE;
				game_state = INIT_BUFFER;
				break;
			case SCREEN_EXIT:
				game_state = EXIT;
				return;
			}
		break;



		case INIT_BUFFER:
			sysvid_clear();                 /* clear buffer */
			draw_map();                     /* draw the map onto the buffer */
			draw_drawStatus();              /* draw the status bar onto the buffer */
#ifdef ENABLE_CHEATS
			draw_infos();                   /* draw the info bar onto the buffer */
#endif
			game_rects = &draw_SCREENRECT;  /* request full buffer refresh */
			game_state = PLAY0;
			return;



		case PAUSE_PRESSED1:
			screen_pause(TRUE);
			game_state = PAUSE_PRESSED1B;
			break;



		case PAUSE_PRESSED1B:
			if (control_status & CONTROL_PAUSE)
				return;
			game_state = PAUSED;
			break;



		case PAUSED:
			if (control_status & CONTROL_PAUSE)
				game_state = PAUSE_PRESSED2;
			if (control_status & CONTROL_EXIT)
				game_state = EXIT;
			return;



		case PAUSE_PRESSED2:
			if (!(control_status & CONTROL_PAUSE)) {
				game_waitevt = FALSE;
				screen_pause(FALSE);
#ifdef ENABLE_SOUND
				syssnd_pause(FALSE, FALSE);
#endif
				game_state = PLAY2;
			}
		return;



		case PLAY0:
			play0();
			break;



		case PLAY1:
			if (control_status & CONTROL_PAUSE) {
#ifdef ENABLE_SOUND
				syssnd_pause(TRUE, FALSE);
#endif
				game_waitevt = TRUE;
				game_state = PAUSE_PRESSED1;
			}
			else if (control_active == FALSE) {
#ifdef ENABLE_SOUND
				syssnd_pause(TRUE, FALSE);
#endif
				game_waitevt = TRUE;
				screen_pause(TRUE);
				game_state = PAUSED;
			}
			else
				game_state = PLAY2;
			break;



		case PLAY2:
			if E_RICK_STTST(E_RICK_STDEAD) {  /* rick is dead */
				if (game_cheat1 || --game_lives) {
					game_state = RESTART;
				} else {
					game_state = GAMEOVER;
				}
			}
			else if (game_chsm)  /* request to chain to next submap */
				game_state = CHAIN_SUBMAP;
			else
				game_state = PLAY3;
			break;



    case PLAY3:
      play3();
      return;



    case CHAIN_SUBMAP:
      if (map_chain())
	game_state = CHAIN_END;
      else {
	game_bullets = 0x06;
	game_bombs = 0x06;
	game_map++;

	if (game_map == 0x04) {
	  /* reached end of game */
	  /* FIXME @292?*/
	}

	game_state = CHAIN_MAP;
      }
      break;



    case CHAIN_MAP:                             /* CHAIN MAP */
      switch (screen_introMap()) {
      case SCREEN_RUNNING:
	return;
      case SCREEN_DONE:
	if (game_map >= 0x04) {  /* reached end of game */
	  sysarg_args_map = 0;
	  sysarg_args_submap = 0;
	  game_state = GAMEOVER;
	}
	else {  /* initialize game */
	  ent_ents[1].x = map_maps[game_map].x;
	  ent_ents[1].y = map_maps[game_map].y;
	  map_frow = (U8)map_maps[game_map].row;
	  game_submap = map_maps[game_map].submap;
	  game_state = CHAIN_END;
	}
	break;
      case SCREEN_EXIT:
	game_state = EXIT;
	return;
      }
      break;



    case CHAIN_END:
      map_init();                     /* initialize the map */
      isave();                        /* save data in case of a restart */
      ent_clprev();                   /* cleanup entities */
      draw_map();                     /* draw the map onto the buffer */
      draw_drawStatus();              /* draw the status bar onto the buffer */
      game_rects = &draw_SCREENRECT;  /* request full screen refresh */
      game_state = PLAY3;
      return;



    case SCROLL_UP:
      switch (scroll_up()) {
      case SCROLL_RUNNING:
	return;
      case SCROLL_DONE:
	game_state = PLAY0;
	break;
      }
      break;



    case SCROLL_DOWN:
      switch (scroll_down()) {
      case SCROLL_RUNNING:
	return;
      case SCROLL_DONE:
	game_state = PLAY0;
	break;
      }
      break;



    case RESTART:
      restart();
      game_state = PLAY0;
      return;



    case GAMEOVER:
      switch (screen_gameover()) {
      case SCREEN_RUNNING:
	return;
      case SCREEN_DONE:
	game_state = GETNAME;
	break;
      case SCREEN_EXIT:
	game_state = EXIT;
	break;
      }
      break;



    case GETNAME:
      switch (screen_getname()) {
      case SCREEN_RUNNING:
	return;
      case SCREEN_DONE:
	game_state = INIT_GAME;
	return;
      case SCREEN_EXIT:
	game_state = EXIT;
	break;
      }
      break;



    case EXIT:
      return;

    }
  }