#include #include #include #include #include namespace game { class entity_t { virtual void render(sf::RenderWindow *window) = 0; }; } namespace world { #define SECTOR_SIZE 16 class tile_t { public: char type; }; class sector_index_t { public: int64_t x, y; sector_index_t (); sector_index_t (int64_t x_, int64_t y_); bool operator<(sector_index_t B) const; }; class sector_t { std::vector entities; public: bool empty = true; tile_t tiles[SECTOR_SIZE * SECTOR_SIZE]; void generate(sector_index_t index); }; class world_t { std::map sectors; public: sector_t *get_sector(sector_index_t index); tile_t *get_tile(ssize_t x, ssize_t y); void link(game::entity_t *entity); void unlink(game::entity_t *entity); void render(sf::RenderWindow *window); }; } namespace interface { class state_t { struct { sf::Vector2f center; int target_zoom = 3; float zoom = 3.0f; bool dragging = false; sf::Vector2f drag_ref; } camera; public: sf::RenderWindow *window; world::world_t *world; state_t(sf::RenderWindow *window_, world::world_t *world_); void tick(void); void render(void); }; }