コード例 #1
0
ファイル: input.cpp プロジェクト: moses7/Epiar
void Input::Handle( list<InputEvent> & events ) {
	if ( Simulation::isPaused() ) return;

	Player *player = Player::Instance();

	if( keyDown[ SDLK_UP ] ) player->Accelerate();
	// TODO It shouldn't be possible to rotate in both directions at once
	if( keyDown[ SDLK_LEFT ] ) player->Rotate( 30.0 );
	if( keyDown[ SDLK_RIGHT ] ) player->Rotate( -30.0 );
	if( keyDown[ SDLK_DOWN ] ){ // Rotate in the opposite direction as you're moving
		player->Rotate( player->directionTowards( player->GetMomentum().GetAngle() + 180 ) );
	}
	// DEBUG CODE
	if( keyDown[ 'c' ] ){  // Rotate towards the center of the Universe
		player->Rotate( player->directionTowards( Coordinate(0,0) ) );
	}
}