nngn
Loading...
Searching...
No Matches
map.h
Go to the documentation of this file.
1#ifndef NNGN_MAP_H
2#define NNGN_MAP_H
3
4#include <vector>
5
6#include "lua/table.h"
7#include "math/vec2.h"
8#include "math/vec3.h"
9#include "utils/def.h"
10#include "utils/flags.h"
11
12namespace nngn {
13
14struct Graphics;
15class Textures;
16
17class Map {
18public:
19 static std::vector<uvec2> load_tiles(
20 std::size_t width, std::size_t height, nngn::lua::table_view tiles);
21 void init(Textures *t) { this->textures = t; }
22 u32 vbo() const { return this->m_vbo; }
23 u32 ebo() const { return this->m_ebo; }
24 bool set_max(std::size_t n);
25 bool set_graphics(Graphics *g);
26 bool load(
27 unsigned int tex, float sprite_scale,
28 float trans_x, float trans_y, float scale_x, float scale_y,
29 unsigned int width, unsigned int height,
31 bool enabled() const { return this->m_flags.is_set(Flag::ENABLED); }
32 bool perspective() const
33 { return this->m_flags.is_set(Flag::PERSPECTIVE); }
34 bool set_enabled(bool e);
35private:
36 enum Flag : uint8_t { ENABLED = 1u << 0, PERSPECTIVE = 1u << 1 };
37 Textures *textures = nullptr;
38 Graphics *graphics = nullptr;
39 Flags<Flag> m_flags = {Flag::ENABLED | Flag::PERSPECTIVE};
40 unsigned int tex = 0;
41 uvec2 size = {};
42 float sprite_scale = 1.0f;
43 vec2 trans = {}, scale = {};
44 std::vector<uvec2> uv = {};
45 std::size_t max = {};
46 u32 m_vbo = {}, m_ebo = {};
47 bool gen() const;
48};
49
50}
51
52#endif
tiles
Definition cathedral.lua:18
Definition map.h:17
unsigned int tex
Definition map.h:40
Flags< Flag > m_flags
Definition map.h:39
std::vector< uvec2 > uv
Definition map.h:44
u32 ebo() const
Definition map.h:23
bool gen() const
Definition map.cpp:85
bool perspective() const
Definition map.h:32
bool set_max(std::size_t n)
Definition map.cpp:38
float sprite_scale
Definition map.h:42
u32 vbo() const
Definition map.h:22
static std::vector< uvec2 > load_tiles(std::size_t width, std::size_t height, nngn::lua::table_view tiles)
Definition map.cpp:73
void init(Textures *t)
Definition map.h:21
u32 m_vbo
Definition map.h:46
uvec2 size
Definition map.h:41
bool set_graphics(Graphics *g)
Definition map.cpp:32
Graphics * graphics
Definition map.h:38
Flag
Definition map.h:36
@ PERSPECTIVE
Definition map.h:36
@ ENABLED
Definition map.h:36
u32 m_ebo
Definition map.h:46
bool set_enabled(bool e)
Definition map.cpp:150
std::size_t max
Definition map.h:45
bool enabled() const
Definition map.h:31
Textures * textures
Definition map.h:37
vec2 trans
Definition map.h:43
vec2 scale
Definition map.h:43
Texture manager, loads and caches image data from files/buffers.
Definition texture.h:34
local n
Definition dump_lights.lua:5
local g
Definition gamma.lua:7
Definition audio.cpp:7
std::uint32_t u32
Definition def.h:14
load
Definition entity.lua:7
Wrapper for a small unsigned integral representing flags.
Definition flags.h:18
constexpr bool is_set(AT a) const
Definition flags.h:45
Definition graphics.h:138
Non-owning reference to a table on the stack.
Definition table.h:166
Operations on table values.
local e
Definition math.lua:4