Player.hpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #include "Particle.hpp"
  26. #include "Circle.hpp"
  27. /**
  28. * @class Player
  29. * @author POSITIVE MENTAL ATTITUDE
  30. * @date 06/09/16
  31. * @file Player.hpp
  32. * @brief TODO Player class is in fact a class for everything related to a moving triangles.
  33. * This has to be moved to an Entity class or something
  34. * and leave the camera and input stuff to the Player class.
  35. */
  36. class Player: public Triangle, public InputTarget<int>, public Collidable
  37. {
  38. public:
  39. Player();
  40. void update(sf::Time delta);
  41. void setTexture(sf::Texture& texture) override;
  42. /**
  43. * @brief
  44. * @param foreground
  45. * @return Returns true if the target died.
  46. */
  47. bool checkCollision(Foreground& foreground);
  48. bool isDead();
  49. Rect getBounds();
  50. sf::Image _image;
  51. sf::Texture _innerTexture;
  52. void setContext(Context* context);
  53. private:
  54. void keyboardControls(sf::Time delta);
  55. void padControls(sf::Time delta);
  56. Context* _context;
  57. std::vector<Bullet> _bullets;
  58. sf::Clock _bulletTimer;
  59. InputMap<int> _inputMap;
  60. float _movement, _movementSpeed, _movementMomentum, _movementAcceleration, _movementSuppresion;
  61. float _rotation, _rotationSpeed, _rotationMomentum, _rotationAcceleration, _rotationSuppresion;
  62. bool _canStrafe;
  63. float _strafe;
  64. bool _hit;
  65. bool _dead;
  66. virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const final override;
  67. sf::Sound _glass;
  68. sf::Sound _deathSound;
  69. ParticleSystem _particleSystem;
  70. int _ammo;
  71. Circle _life;
  72. Circle _mana;
  73. };