Example #1
0
static void handleWindowChildEvents(FrameworkWindow *window, long signalSet) {
  FrameworkWindow *i = window->children;
  while(i) {
    FrameworkWindow *next = i->next;
    handleWindowEvents(i, signalSet);
    i = next;
  }
}
Example #2
0
void GameApp::run()
{
	while(window.isOpen())
	{
		handleWindowEvents();
		update();
		render();
	}
}
void MainGameState::gameTick( float deltaTime ) {
    // Pass window events to the InputHandler.
    handleWindowEvents();
    // Process the player's input.
    inputHandler.processInputs( deltaTime );
    // Advance the GUI.
    GUI.tick();
    // Test if the player is dead.
    if( player.isDead() ) {
        GameState *deadGameState = 
                new DeadGameState( gameWindow, player );
        gameWindow->pushNewState( deadGameState );
    }
    // Test for tutorial triggers.
    tutorials.testTriggers( world, player );
}
void ShopGameState::gameTick( float deltaTime ) {
    handleWindowEvents();
    inputHandler.processInputs();
}
Example #5
0
void Game::update(sf::Time elapsedTime)
{
	handleWindowEvents();

	switch (gameState)
	{
	case GameState::Welcome:
		{
			gameGraphics.update(elapsedTime);

			gameGraphics.setSmallStatus("Press Enter To Begin PlAIing");
			gameGraphics.setBigStatus(versusText);

			if (Keyboard::isKeyPressed(Keyboard::Return)) 
			{
				gameState = GameState::Playing;
				gameSounds.welcomeMusic.stop();
				gameSounds.backgroundMusic.play();
				gameSounds.waterMusic.play();
				gameSounds.creditsMusic.stop();
			}
			if (Keyboard::isKeyPressed(Keyboard::Escape)) window.close();

			break;
		}
	case GameState::Playing:
		{
			remainingTime -= elapsedTime.asSeconds();

			if (raft1.getHealth() > 0)
			{
				raft1.controls = player1.controlRaft(&infoProvider1);
				raft1.update(elapsedTime);
			}

			if (map.fishLocations.empty() || remainingTime <= 0 || raft1.getHealth() == 0 || raft2.getHealth() == 0)
			{
				gameState = GameState::GameOver;
				gameSounds.welcomeMusic.stop();
				gameSounds.backgroundMusic.stop();
				gameSounds.waterMusic.stop();
				gameSounds.creditsMusic.play();
			}

			if (raft2.getHealth() > 0)
			{
				raft2.controls = player2.controlRaft(&infoProvider2);
				raft2.update(elapsedTime);
			}

			if (map.fishLocations.empty() || remainingTime <= 0 || raft1.getHealth() == 0 || raft2.getHealth() == 0)
			{
				gameState = GameState::GameOver;
				gameSounds.welcomeMusic.stop();
				gameSounds.backgroundMusic.stop();
				gameSounds.waterMusic.stop();
				gameSounds.creditsMusic.play();
			}

			cannonBallsManager.update(elapsedTime);

			if (map.fishLocations.empty() || remainingTime <= 0 || raft1.getHealth() == 0 || raft2.getHealth() == 0)
			{
				gameState = GameState::GameOver;
				gameSounds.welcomeMusic.stop();
				gameSounds.backgroundMusic.stop();
				gameSounds.waterMusic.stop();
				gameSounds.creditsMusic.play();
			}

			gameGraphics.update(elapsedTime);

			gameGraphics.setSmallStatus(versusText);
			gameGraphics.setBigStatus(NULL);

			if (Keyboard::isKeyPressed(Keyboard::Escape))
			{
				gameState = GameState::Paused;
				gameSounds.welcomeMusic.stop();
				gameSounds.backgroundMusic.pause();
				gameSounds.waterMusic.pause();
				gameSounds.creditsMusic.stop();
			}

			break;
		}
	case GameState::Paused:
		{
			gameGraphics.setBigStatus("Game Paused");
			gameGraphics.setSmallStatus("Press E To Exit. Press Enter To Resume.");
			if (Keyboard::isKeyPressed(Keyboard::E)) window.close();
			if (Keyboard::isKeyPressed(Keyboard::Return))
			{
				gameState = GameState::Playing;
				gameSounds.welcomeMusic.stop();
				gameSounds.backgroundMusic.play();
				gameSounds.waterMusic.play();
				gameSounds.creditsMusic.stop();
			}

			break;
		}
	case GameState::GameOver:
		{
			gameGraphics.update(elapsedTime);

			if (raft1.getHealth() == 0)
			{
				gameGraphics.setBigStatus(player2WinningText);
			}
			else if(raft2.getHealth() == 0)
			{
				gameGraphics.setBigStatus(player1WinningText);
			}
			else
			{
				if (raft1.getNumberOfFish() > raft2.getNumberOfFish())
				{
					gameGraphics.setBigStatus(player1WinningText);
				}
				else if (raft1.getNumberOfFish() < raft2.getNumberOfFish())
				{
					gameGraphics.setBigStatus(player2WinningText);
				}
				else
				{
					if (raft1.remainingTimeAtWhichLastFishCollected < raft2.remainingTimeAtWhichLastFishCollected)
					{
						gameGraphics.setBigStatus(player2WinningText);
					}
					else if (raft2.remainingTimeAtWhichLastFishCollected < raft1.remainingTimeAtWhichLastFishCollected)
					{
						gameGraphics.setBigStatus(player1WinningText);
					}
					else
					{
						gameGraphics.setBigStatus("It's a tie!");
					}
				}
			}
			gameGraphics.setSmallStatus("Press Escape To Exit.");

			if (Keyboard::isKeyPressed(Keyboard::Escape)) window.close();
			//if (Keyboard::isKeyPressed(Keyboard::Return)) initialise();

			break;
		}
	}
	
}