]> git.lizzy.rs Git - shadowclad.git/blob - src/game/level.h
Housekeeping
[shadowclad.git] / src / game / level.h
1 #ifndef LEVEL_H_
2 #define LEVEL_H_
3
4 #include <stdint.h>
5
6 #include "engine/asset.h"
7 #include "engine/tga.h"
8
9 typedef enum {
10         BLOCKTYPE_SPACE,
11         BLOCKTYPE_OBSTACLE_X,
12         BLOCKTYPE_OBSTACLE_Z,
13         BLOCKTYPE_OBSTACLE
14 } BlockType;
15
16 typedef struct {
17         const BlockType type;
18         const Solid* solid;
19 } Block;
20
21 typedef struct {
22         size_t width;
23         size_t depth;
24         Block** blocks;
25 } BlockGrid;
26
27 #define BLOCKGRID_CELL_SIZE 2.5f
28
29 BlockGrid levelGrid;
30
31 void initLevel();
32 void startLevel();
33 void buildLevelFromImage(TgaImage* image);
34
35 static inline Block* getBlockFromGrid(BlockGrid grid, size_t x, size_t z) {
36         return grid.blocks[(z * grid.width) + x];
37 }
38
39 static inline void setBlockInGrid(BlockGrid grid, size_t x, size_t z, Block* block) {
40         grid.blocks[(z * grid.width) + x] = block;
41 }
42
43 #endif // LEVEL_H_