MouseCtrl.cpp 797 B

1234567891011121314151617181920212223242526272829303132333435363738
  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->getMouseKey(1);
  10. // Shield activation
  11. m_shield = m_input->getMouseKey(3);
  12. // Jumping
  13. m_jump = m_input->getKey(SDL_SCANCODE_SPACE);
  14. // Movement
  15. m_move.SetZero();
  16. if (m_input->getKey(SDL_SCANCODE_W))
  17. m_move.y = -1.0f;
  18. else if (m_input->getKey(SDL_SCANCODE_S))
  19. m_move.y = 1.0f;
  20. if (m_input->getKey(SDL_SCANCODE_D))
  21. m_move.x = 1.0f;
  22. else if (m_input->getKey(SDL_SCANCODE_A))
  23. m_move.x = -1.0f;
  24. // Visor
  25. m_visor.x = (float) m_input->getXFromCenter();
  26. m_visor.y = (float) m_input->getYFromCenter();
  27. m_visor.Normalize();
  28. }