Beispiel #1
0
void handle_input(Outbreak * outbreak) {
  SDL_Event event;

  while (SDL_PollEvent(&event)) {
    if (event.type == SDL_KEYDOWN && event.key.keysym.sym == CONTROLS_PAUSE) {
      outbreak->paused = !outbreak->paused;
    } else if (event.type == SDL_QUIT) {
      outbreak->quit = TRUE;
    }

    if (!outbreak->paused) {
      switch(event.type) {
        case SDL_KEYDOWN:
          if (event.key.keysym.sym == CONTROLS_RIGHT) {
            set_object_velocity_x(outbreak->player, PADDLE_VELOCITY);
          } else if (event.key.keysym.sym == CONTROLS_LEFT) {
            set_object_velocity_x(outbreak->player, -PADDLE_VELOCITY);
          } else if (event.key.keysym.sym == CONTROLS_LAUNCH) {
            launch_ball(outbreak->ball);
          }
          break;

        case SDL_KEYUP:
          if (event.key.keysym.sym == CONTROLS_RIGHT) {
            if (object_direction_x(outbreak->player) == DIRECTION_RIGHT) {
              set_object_velocity_x(outbreak->player, 0);
            }
          } else if (event.key.keysym.sym == CONTROLS_LEFT) {
            if (object_direction_x(outbreak->player) == DIRECTION_LEFT) {
              set_object_velocity_x(outbreak->player, 0);
            }
          }
          break;

        case SDL_MOUSEBUTTONDOWN:
          if (event.button.button == MOUSE_CONTROLS_LAUNCH) {
            launch_ball(outbreak->ball);
          }
          break;

        case SDL_MOUSEMOTION:
          set_object_velocity_x(outbreak->player, 0);
          set_object_x(outbreak->player, event.motion.x - object_width(outbreak->player) / 2);
          if (object_offscreen(outbreak->player)) {
            set_object_x(outbreak->player, object_x(outbreak->player) < 0 ? 0 : SCREEN_WIDTH - object_width(outbreak->player));
          }
          break;
      }
    }
  }
}
Beispiel #2
0
/**
 * When valid playfield is already set, the player does not have
 * to press Launch to fire the ball; it is automatic.  Schedule
 * this launch as soon as we know a ball exited the trough (we
 * do not have to see the shooter).
 */
CALLSET_ENTRY (serve, dev_trough_kick_success)
{
#ifdef HAVE_AUTO_SERVE
	if (valid_playfield)
		launch_ball ();
#endif
}
void GameScene::update(double dt) {
  // таймер запуска новых шариков
  _time_left -= (int)(dt * 1000.0f);
  if(_time_left <= 0) {
    _time_left = _timer;
    launch_ball();
  }
  // пусть м¤чики движутс¤
}
Beispiel #4
0
/**
 * When valid playfield is already set, the player does not have
 * to press Launch to fire the ball; it is automatic.  Schedule
 * this launch as soon as we know a ball exited the trough (we
 * do not have to see the shooter).
 */
CALLSET_ENTRY (serve, dev_trough_kick_success) {
#ifndef MACHINE_DEMO_MAN
	#ifdef HAVE_AUTO_SERVE
		if (valid_playfield) {
			task_sleep (TIME_200MS);
			launch_ball ();
		}
	#endif
#endif
} //end of function
Beispiel #5
0
/**
 * If we see the shooter at any other time than a trough kick,
 * we will autolaunch it but not if the door is open or we are
 * in tournament mode.
 */
CALLSET_ENTRY (serve, sw_shooter)
{
	ball_search_timer_reset ();
	if (valid_playfield
		&& !tournament_mode_enabled
		&& !global_flag_test (GLOBAL_FLAG_COIN_DOOR_OPENED))
	{
		/* TODO - this might be game specific.  For example, Simpsons Pinball
		Party would give you a manual skill shot here except during
		multiball. */
		launch_ball ();
	}
}
Beispiel #6
0
/**
 * If we see the shooter at any other time than a trough kick,
 * we will autolaunch it but not if the door is open or we are
 * in tournament mode.
 */
CALLSET_ENTRY (serve, sw_shooter) {
#ifdef MACHINE_SHOOTER_SWITCH
	if (!switch_poll_logical (MACHINE_SHOOTER_SWITCH))		return;
	ball_search_timer_reset ();
	if (	valid_playfield
		&& !tournament_mode_enabled
		&& !global_flag_test (GLOBAL_FLAG_COIN_DOOR_OPENED)
		&& !MB_SERVING) {
		task_sleep (MACHINE_SHOOTER_SWITCH_DELAY);
		launch_ball ();
	}//end of if
#endif
} //end of function
Beispiel #7
0
void user_input(unsigned char key, int x, int y)
{
     if(key == 13)
        launch_ball();
}