Moved the animated scene into its own system for better development.
This commit is contained in:
parent
49c9702041
commit
4f39f2a504
7 changed files with 209 additions and 159 deletions
44
scene.hpp
Normal file
44
scene.hpp
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#pragma once
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include "components.hpp"
|
||||
#include "textures.hpp"
|
||||
#include <SFML/Graphics/RenderWindow.hpp>
|
||||
#include <guecs/ui.hpp>
|
||||
|
||||
namespace scene {
|
||||
using std::shared_ptr;
|
||||
using namespace textures;
|
||||
|
||||
struct Element {
|
||||
textures::SpriteTexture st;
|
||||
components::Animation anim;
|
||||
std::string cell;
|
||||
float scale_x;
|
||||
float scale_y;
|
||||
float x;
|
||||
float y;
|
||||
bool at_mid=false;
|
||||
sf::Vector2f pos{0,0};
|
||||
};
|
||||
|
||||
struct Engine {
|
||||
guecs::UI $ui;
|
||||
SpriteTexture $floor_sprite;
|
||||
components::AnimatedScene& $scene;
|
||||
std::unordered_map<std::string, int> $actor_name_ids;
|
||||
std::vector<Element> $fixtures;
|
||||
std::vector<Element> $actors;
|
||||
|
||||
Engine(components::AnimatedScene& scene);
|
||||
|
||||
void init();
|
||||
void render(sf::RenderWindow& window);
|
||||
bool mouse(float x, float y, guecs::Modifiers mods);
|
||||
sf::Vector2f position_sprite(textures::SpriteTexture& st, const std::string& cell_name, float scale_x, float scale_y, bool at_mid, float x_diff=0.0f, float y_diff=0.0f);
|
||||
|
||||
void move_actor(const std::string& actor, const std::string& cell_name);
|
||||
void animate_actor(const std::string& actor);
|
||||
void play_animations();
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue