Foreground.hpp 2.3 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 <vector>
  19. #include <SFML/Graphics.hpp>
  20. #include "Utility.hpp"
  21. /**
  22. * @class Foreground
  23. * @author POSITIVE MENTAL ATTITUDE
  24. * @date 06/09/16
  25. * @file Foreground.hpp
  26. * @brief The destructible foreground.
  27. */
  28. class Foreground: public sf::Drawable
  29. {
  30. public:
  31. Foreground();
  32. ~Foreground();
  33. void create(sf::Image& foreground, sf::Image& normal, sf::Image& map);
  34. void create(std::string foreground, std::string normal, std::string map);
  35. void setResolution(sf::Vector2u resolution);
  36. void setPosition(sf::Vector2f position);
  37. void reloadFromTile(int x, int y, bool neighbouring = false);
  38. void reloadFromPixel(int x, int y, bool neighbouring = false);
  39. bool destroy(unsigned x, unsigned y);
  40. const sf::Vector2u getSize() const;
  41. const unsigned getTileSize() const;
  42. unsigned const tileAlpha(unsigned x, unsigned y, unsigned pixelX, unsigned pixelY);
  43. void renderNormals(bool render);
  44. void move(sf::Vector2f movement);
  45. void rotate(float rotation);
  46. const Rect getBounds() const;
  47. const sf::Vector2f getWormholePosition() const;
  48. const bool getStarPosition(sf::Vector2f& starPosition);
  49. private:
  50. void draw(sf::RenderTarget& target, sf::RenderStates states) const;
  51. std::vector<std::pair<sf::Image, sf::Texture>> _tiles;
  52. std::vector<std::vector<sf::Sprite>> _sprites;
  53. std::vector<std::pair<sf::Image, sf::Texture>> _normalTiles;
  54. std::vector<std::vector<sf::Sprite>> _normalSprites;
  55. sf::Vector2u _renderCount;
  56. sf::Vector2u _tileCount;
  57. unsigned _tileSize;
  58. sf::Vector2u _position;
  59. bool _renderNormals;
  60. sf::Vector2u _wormholePosition;
  61. std::vector<sf::Vector2u> _starPosition;
  62. };