Advertisement
venik2405

Untitled

Dec 19th, 2021
967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. void Player::updateInput()
  2. {
  3.     this->speed = engine.getSpeed();
  4.     if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)) {
  5.         this->engine.brake();
  6.     }
  7.     else if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)) {
  8.         this->engine.gas();
  9.     }
  10.     else {
  11.         this->engine.Idle();
  12.     }
  13.  
  14.     if (Keyboard::isKeyPressed(Keyboard::W) && canMoveUp())
  15.     {
  16.         this->engine.moveUp();
  17.     }
  18.  
  19.  
  20.     if (Keyboard::isKeyPressed(Keyboard::S) && canMoveDown())
  21.     {
  22.         //действия, когда нажали
  23.         this->engine.moveDown();
  24.     }
  25.  
  26.     if (Keyboard::isKeyPressed(Keyboard::LShift))
  27.     {
  28.         this->engine.nitro();
  29.         isNitring = true;
  30.         if (engine.canNitro())
  31.         {
  32.             if (nitro_s.getStatus() == SoundSource::Status::Stopped)
  33.                 nitro_s.play();
  34.             isNitring = true;
  35.         }
  36.     }
  37.     else {
  38.         nitro_s.stop();
  39.         isNitring = false;
  40.     }
  41.  
  42.  
  43.     if (sf::Keyboard::isKeyPressed(sf::Keyboard::Q)) {
  44.         this->engine.gearDown();
  45.     }
  46.     else if (sf::Keyboard::isKeyPressed(sf::Keyboard::E)) {
  47.         this->engine.gearUp();
  48.     }
  49.     this->left_wh.rotate(this->speed * 0.6f);
  50.     this->right_wh.rotate(this->speed * 0.6f);
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement