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;
|
||||
}
|
||||
|
||||
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.up = sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Up);
|
||||
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) {
|
||||
pacManAI.update(pacMan, pellets);
|
||||
pacMan.update(delta,
|
||||
pacManAI.suggestedDirection()
|
||||
//inputState.direction()
|
||||
);
|
||||
pacMan.update(delta, inputState.enableAI ? pacManAI.suggestedDirection() : inputState.direction());
|
||||
|
||||
if (isPacManDying()) {
|
||||
handleDeathAnimation(delta);
|
||||
|
|
|
@ -9,6 +9,7 @@ public:
|
|||
bool down = false;
|
||||
bool left = false;
|
||||
bool right = false;
|
||||
bool enableAI = false;
|
||||
|
||||
Direction direction() const {
|
||||
if (left)
|
||||
|
|
Loading…
Reference in a new issue