blob: aaf1cadacd14c1be56a7722e131215672ca992bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#include <iostream>
#include <cstdint>
#include <cmath>
#include <map>
#include <SFML/Graphics.hpp>
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<game::entity_t*> entities;
public:
bool empty = true;
tile_t tiles[SECTOR_SIZE * SECTOR_SIZE];
void generate(sector_index_t index);
};
class world_t {
std::map<sector_index_t, sector_t> 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);
};
}
|