Player.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * Triangles
  3. * Copyright (C) 2016 POSITIVE MENTAL ATTITUDE
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, version 3 of the License.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #pragma once
  18. #include <SFML/Audio.hpp>
  19. #include "Triangle.hpp"
  20. #include "InputTarget.hpp"
  21. #include "Utility.hpp"
  22. #include "Bullet.hpp"
  23. #include "Collidable.hpp"
  24. #include "Context.hpp"
  25. /**
  26. * @class Player
  27. * @author POSITIVE MENTAL ATTITUDE
  28. * @date 06/09/16
  29. * @file Player.hpp
  30. * @brief TODO Player class is in fact a class for everything related to a moving triangles.
  31. * This has to be moved to an Entity class or something
  32. * and leave the camera and input stuff to the Player class.
  33. */
  34. class Player: public Triangle, public InputTarget<int>, public Collidable
  35. {
  36. public:
  37. Player();
  38. void update(sf::Time delta);
  39. void setTexture(sf::Texture& texture) override;
  40. /**
  41. * @brief
  42. * @param foreground
  43. * @return Returns true if the target died.
  44. */
  45. bool checkCollision(Foreground& foreground);
  46. bool isDead();
  47. Rect getBounds();
  48. sf::Image _image;
  49. sf::Texture _innerTexture;
  50. void setContext(Context* context);
  51. private:
  52. Context* _context;
  53. std::vector<Bullet> _bullets;
  54. sf::Clock _bulletTimer;
  55. InputMap<int> _inputMap;
  56. float _movement, _movementSpeed, _movementMomentum, _movementAcceleration, _movementSuppresion;
  57. float _rotation, _rotationSpeed, _rotationMomentum, _rotationAcceleration, _rotationSuppresion;
  58. bool _canStrafe;
  59. float _strafe;
  60. bool _hit;
  61. bool _dead;
  62. virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const final override;
  63. sf::Sound _glass;
  64. sf::Sound _deathSound;
  65. };