raycaster/scene.hpp

46 lines
1.2 KiB
C++

#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 {
std::string name;
textures::SpriteTexture st;
components::Animation anim;
std::string cell;
float scale_x = 1.0f;
float scale_y = 1.0f;
float x = 0;
float y = 0;
bool at_mid=false;
sf::Vector2f pos{0,0};
};
struct Engine {
guecs::UI $ui;
components::AnimatedScene& $scene;
std::string $layout;
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();
};
}