Bullet.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/Graphics.hpp>
  19. #include <SFML/Audio.hpp>
  20. #include "Collidable.hpp"
  21. /**
  22. * @class Bullet
  23. * @author POSITIVE MENTAL ATTITUDE
  24. * @date 06/09/16
  25. * @file Bullet.hpp
  26. * @brief When created, it moves forward until it crashes with a wall.
  27. */
  28. class Bullet: public sf::Drawable, public sf::Transformable, public Collidable
  29. {
  30. public:
  31. Bullet() = delete;
  32. Bullet(float rotation, sf::Vector2f initialPosition, sf::SoundBuffer& buffer1, sf::SoundBuffer& buffer2, Foreground* foreground);
  33. void setTexture(sf::Texture& texture);
  34. void update(sf::Time delta, sf::Vector2f position);
  35. const bool isDead() const;
  36. private:
  37. sf::Vertex _vertex[4];
  38. const sf::Texture* _texture;
  39. virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
  40. void destroyPixels(int& k, int x, int y);
  41. sf::Sound _sound;
  42. sf::Sound _explosion;
  43. Foreground* _foreground;
  44. bool _hit;
  45. bool _dead;
  46. };