Commit 30299431 authored by louiz’'s avatar louiz’

Add the MobilitySprite class

It manages all the sprites and various graphical things related to drawing
the path/movement etc
parent 47f8de07
#include <gui/camera/mobility_sprites.hpp>
#include <assets/assets_manager.hpp>
sf::Texture MobilitySprites::texture;
sf::Sprite MobilitySprites::flag_sprite;
void MobilitySprites::init()
{
MobilitySprites::texture.loadFromFile(AssetsManager::full_name("images/game.png"));
MobilitySprites::texture.setSmooth(true);
MobilitySprites::flag_sprite.setTexture(MobilitySprites::texture);
MobilitySprites::flag_sprite.setTextureRect({{396, 260}, {128, 250}});
MobilitySprites::flag_sprite.setOrigin(20, 240);
MobilitySprites::flag_sprite.setScale(0.3, 0.3);
}
void MobilitySprites::insert_flag_sprites(const Path& path,
std::vector<std::unique_ptr<SimpleWorldSprite>>& flags)
{
for (const Position& pos: path)
{
auto sprite = std::make_unique<SimpleWorldSprite>(pos, MobilitySprites::flag_sprite);
flags.push_back(std::move(sprite));
}
}
#ifndef MOBILITY_SPRITES_HPP_INCLUDED
#define MOBILITY_SPRITES_HPP_INCLUDED
/**
* Gives a way to draw all the camera sprites regarding the mobility of
* world entities. For example the flags to represent the path
* selected entity is following.
*/
#include <gui/sprites/simple_world_sprite.hpp>
#include <world/path.hpp>
#include <SFML/Graphics.hpp>
#include <vector>
#include <memory>
class MobilitySprites
{
public:
MobilitySprites() = default;
~MobilitySprites() = default;
static void init();
static void insert_flag_sprites(const Path& path,
std::vector<std::unique_ptr<SimpleWorldSprite>>& flags);
private:
static sf::Texture texture;
static sf::Sprite flag_sprite;
MobilitySprites(const MobilitySprites&) = delete;
MobilitySprites(MobilitySprites&&) = delete;
MobilitySprites& operator=(const MobilitySprites&) = delete;
MobilitySprites& operator=(MobilitySprites&&) = delete;
};
#endif /* MOBILITY_SPRITES_HPP_INCLUDED */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment