void TwoPlayerInputController::keyProcess(Tank* playerToMove, Tank* playerCanBeCollision, const float dt) const
{
playerToMove->updateDirect();
if (sf::Keyboard::isKeyPressed(playerToMove->keysAssignment.moveUpCommand->getKey()))
{
playerToMove->keysAssignment.moveUpCommand->execute(playerToMove, dt);
}
if (sf::Keyboard::isKeyPressed(playerToMove->keysAssignment.moveDownCommand->getKey()))
{
playerToMove->keysAssignment.moveDownCommand->execute(playerToMove, dt);
}
if (sf::Keyboard::isKeyPressed(playerToMove->keysAssignment.moveLeftCommand->getKey()))
{
playerToMove->keysAssignment.moveLeftCommand->execute(playerToMove, dt);
}
if (sf::Keyboard::isKeyPressed(playerToMove->keysAssignment.moveRightCommand->getKey()))
{
playerToMove->keysAssignment.moveRightCommand->execute(playerToMove, dt);
}
}
void TwoPlayerInputController::keysProcessing(const float dt) const
{
keyProcess(player1, player2, dt);
keyProcess(player2, player1, dt);
}
void Game::updateEvents()
{
sf::Event ev;
while (_window->pollEvent(ev))
{
if (ev.type == sf::Event::Closed)
{
_window->close();
}
// Движение персонажей
inputController_->keysProcessing(_deltaTime);
}
}