MouseCtrl.cpp 810 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // Created by jovian on 18/07/17.
  3. //
  4. #include "MouseCtrl.h"
  5. MouseCtrl::MouseCtrl(Input *input) : m_input(input) {
  6. }
  7. void MouseCtrl::refresh() {
  8. // Firing
  9. m_firing = m_input->getKey(SDL_SCANCODE_SPACE);
  10. // Shield activation
  11. m_shield = m_input->getKey(SDL_SCANCODE_S);
  12. // Boosting
  13. m_boost = m_input->getMouseKey(1);
  14. // Visor
  15. m_visor.x = (float) m_input->getXFromCenter();
  16. m_visor.y = (float) m_input->getYFromCenter();
  17. m_visor.Normalize();
  18. // Acceleration
  19. if (m_input->getKey(SDL_SCANCODE_Z))
  20. m_acceleration = 1.0f;
  21. else
  22. m_acceleration = 0.0f;
  23. // Torque
  24. if (m_input->getKey(SDL_SCANCODE_A))
  25. m_torque = -1.0f;
  26. else if (m_input->getKey(SDL_SCANCODE_D))
  27. m_torque = 1.0f;
  28. else
  29. m_torque = 0.0f;
  30. }