Exemple #1
0
void ball_step(void)
{
  int x, y;
  switch ( game_get_state() ) {
    case START:
      remaining = 3;
      init_ball();
      break;

    case NEXTSTAGE:
      init_ball();
      break;

    case REMAINING:
      break;

    case RUNNING:
      x = old_x + dx; y = old_y + dy;

      if ( x != old_x && ( x <= 0 || LCD_WIDTH-ball.width < x )) {
        dx = dx > 0 ? -1*BALL_DX : BALL_DX;
        return;
      }

      if ( y != old_y && y <= 0 ) {
        dy = dy > 0 ? -1*BALL_DY : BALL_DY;
        return;
      } else if ( y!= old_y && LCD_HEIGHT-ball.width < y ) {
        if ( remaining <= 1 ) {
          game_set_state(DEAD);
        } else {
          draw_box(&ball, ball.x, ball.y, COLOR_BLACK);
          remaining--;
          init_ball();
          game_set_state(REMAINING);
        }
        return;
      }

      move_box(&ball, x, y, BALL_COLOR);
      old_x = x; old_y = y;
      break;

    case CLEAR:
      draw_box(&ball, old_x, old_y, BALL_COLOR);
      break;

    case DEAD:
      break;

    case RESTART:
      remaining = 3;
      init_ball();
      break;
  }
}
Exemple #2
0
void hp_step(){
  
  hword color = COLOR_WHITE;
  
  switch (game_get_state()) {
  case START:
    hp_initialize();
    stock_initialize();
    break;
    
  case RUNNING:
    draw_box(&hpbar, hpbar.x, hpbar.y, COLOR_RED);
    if(hp == 0){
      stock_lose();
      if(stock_count == 0){
	game_set_state(DEAD);
	break;
      }
      game_set_state(MISS);
    }
    break;
    
  case MISS:    
    if(stock_count == 0)
      game_set_state(DEAD);
    hp = 50;
    hpbar.width = hp;   
    break;
    
  case DEAD:
    break;
    
  case RESTART:
    hp_initialize();
    stock_initialize();
    break;
    
  case CLEAR:
    break;
    
  }
  
}
Exemple #3
0
void game_step(void)
{
  int key = gba_register(KEY_STATUS);
  
  switch (game_get_state()) {
  case START:

    if (! (key & KEY_START))  //STARTキーが押された
      game_set_state(RUNNING);
    break;

  case RUNNING:
    if (! (key & KEY_R))  //Rキーが押された(デバッグ用)
      game_set_state(CLEAR);
    if (! (key & KEY_L))  //Lキーが押された(デバッグ用)
      game_set_state(MISS);
    break;

  case MISS:
    if (! (key & KEY_START))  //STARTキーが押された
      game_set_state(RUNNING);
    break;
    
  case DEAD:
    if (! (key & KEY_START))  //STARTキーが押された
      game_set_state(RESTART);
    break;
    
  case RESTART:
    /* 次のティックはRUNNING状態にする.*/
    game_set_state(RUNNING);
    break;

  case CLEAR:
    if (! (key & KEY_SELECT))  //SELECTキーが押された(STARTの場合1tickだけボタン押さないとRUNNINGに移動してしまうため)
      game_set_state(START);
    break;
  }
}
Exemple #4
0
void game_exit(game_t g)
{
	game_set_state(g, GAME_STATE_STOPPED);
}
Exemple #5
0
void game_step(void)
{
  switch ( game_get_state() ) {
    case START:
      current_stage = 0;
      draw_string("Press START key to start.", 23, 85, COLOR_WHITE);
      if ( get_key_state(KEY_START) ) {
        draw_string("Press START key to start.", 23, 85, COLOR_BLACK);
        game_set_state(REMAINING);
      }
      break;

    case NEXTSTAGE:
      game_set_state(REMAINING);
      break;

    case REMAINING:
      draw_string("stage ", 95, 75, COLOR_WHITE);
      draw_num(current_stage+1, 140, 75, COLOR_WHITE);
      draw_string("ball x", 90, 85, COLOR_YELLOW);
      draw_num(ball_get_remaining(), 145, 85, COLOR_YELLOW);
      delay(30000);
      draw_string("stage ", 95, 75, COLOR_BLACK);
      draw_num(current_stage+1, 140, 75, COLOR_BLACK);
      draw_string("ball x", 90, 85, COLOR_BLACK);
      draw_num(ball_get_remaining(), 145, 85, COLOR_BLACK);
      game_set_state(RUNNING);
      break;

    case RUNNING:
      // for Debug
      if ( get_key_state(KEY_SELECT) ) {
        game_set_state(CLEAR);
      }
      break;

    case DEAD:
      draw_string("GAME OVER", 85, 70, COLOR_RED);
      draw_string("Press START key to restart.", 16, 85, COLOR_WHITE);
      if ( get_key_state(KEY_START) ) {
        init_screen();
        game_set_state(RESTART);
      }
      break;

    case CLEAR:
      if ( current_stage < 2 ) {
        draw_string("CLEAR!!", 95, 70, COLOR_ITF);
        draw_string("Press A key to", 65, 85, COLOR_WHITE);
        draw_string("next stage!", 80, 95, COLOR_WHITE);
        if ( get_key_state(KEY_A) ) {
          init_screen();
          current_stage++;
          game_set_state(NEXTSTAGE);
        }
      } else {
        draw_string("CLEAR!!", 95, 70, COLOR_ITF);
        draw_string("Press START key to restart.", 16, 85, COLOR_WHITE);
        if ( get_key_state(KEY_START) ) {
          init_screen();
          game_set_state(RESTART);
        }
      }
      break;

    case RESTART:
      current_stage = 0;
      game_set_state(START);
      break;
  }
}
Exemple #6
0
void multi_change_state(struct game* game, game_state_t state_to) {
	switch(game_get_state(game)) {
	case PLAYING:
	case PAUSED:
		switch(state_to) {
		case SCORE:
#ifdef USE_WIIMOTE
		//= 0)
			//wiimote_set_rumble(player->id, 0);
#endif
			game_set_state(game, SCORE);
			if(player_get_nb_player_alive(game) == 1)
				game_inc_score(game, player_get_id_player_alive(game));

			break;
		case CHOOSE_MAP:
			game_set_state(game, CHOOSE_MAP);
			game_reset_lvl_map(game);
			game_reset_scores(game);

			break;
		default:
			break;
		}
		break;

	case CHOOSE_MAP:
		switch(state_to) {
		case PLAYING:
			game_set_state(game, PLAYING);
			window_resize(map_get_width(level_get_curr_map(game_get_curr_level(game))) * SIZE_BLOC, map_get_height(level_get_curr_map(game_get_curr_level(game))) * SIZE_BLOC + BANNER_HEIGHT + LINE_HEIGHT);
			players_from_map(game, level_get_curr_map(game_get_curr_level(game)));
			player_reset(game, 1, 1, 2, 4, 0);

			break;
		default:
			break;
		}
		break;

	case SCORE:
		switch(state_to) {
		case PLAYING:
			game_set_state(game, PLAYING);
			game_reset_lvl_map(game);
			level_set_cur_map(game_get_curr_level(game), game_get_pos(game));
			players_from_map(game, level_get_curr_map(game_get_curr_level(game)));
			player_reset(game, 1, 1, 2, 4, 0);


			break;
		case CHOOSE_MAP:
			game_set_state(game, CHOOSE_MAP);
			game_reset_lvl_map(game);
			game_reset_scores(game);

			break;
		default:
			break;
		}

		break;
	default:
		break;
	}
}