Pressing A switches from the player to the AI.
This commit is contained in:
parent
bc57112aac
commit
d3e7ed1f46
3 changed files with 6 additions and 4 deletions
|
@ -37,6 +37,10 @@ void Game::processEvents(InputState & inputState) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event && event.value().type == sf::Event::KeyPressed && event.value().key.code == sf::Keyboard::A) {
|
||||||
|
inputState.enableAI = !inputState.enableAI;
|
||||||
|
}
|
||||||
|
|
||||||
inputState.down = sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Down);
|
inputState.down = sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Down);
|
||||||
inputState.up = sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Up);
|
inputState.up = sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Up);
|
||||||
inputState.left = sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Left);
|
inputState.left = sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Left);
|
||||||
|
|
|
@ -8,10 +8,7 @@ constexpr int POWER_PELLET_POINTS = 50;
|
||||||
|
|
||||||
void GameState::step(std::chrono::milliseconds delta) {
|
void GameState::step(std::chrono::milliseconds delta) {
|
||||||
pacManAI.update(pacMan, pellets);
|
pacManAI.update(pacMan, pellets);
|
||||||
pacMan.update(delta,
|
pacMan.update(delta, inputState.enableAI ? pacManAI.suggestedDirection() : inputState.direction());
|
||||||
pacManAI.suggestedDirection()
|
|
||||||
//inputState.direction()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isPacManDying()) {
|
if (isPacManDying()) {
|
||||||
handleDeathAnimation(delta);
|
handleDeathAnimation(delta);
|
||||||
|
|
|
@ -9,6 +9,7 @@ public:
|
||||||
bool down = false;
|
bool down = false;
|
||||||
bool left = false;
|
bool left = false;
|
||||||
bool right = false;
|
bool right = false;
|
||||||
|
bool enableAI = false;
|
||||||
|
|
||||||
Direction direction() const {
|
Direction direction() const {
|
||||||
if (left)
|
if (left)
|
||||||
|
|
Loading…
Reference in a new issue