#include <stdint.h>
#include "engine/asset.h"
-#include "engine/tga.h"
-typedef enum {
- BLOCKTYPE_SPACE,
- BLOCKTYPE_OBSTACLE_X,
- BLOCKTYPE_OBSTACLE_Z,
- BLOCKTYPE_OBSTACLE
-} BlockType;
+enum BlockType {
+ BLOCKTYPE_SPACE = 0,
+ BLOCKTYPE_OBSTACLE_X = 1 << 0,
+ BLOCKTYPE_OBSTACLE_Z = 1 << 1
+};
-typedef struct {
- const BlockType type;
+enum Obstacle {
+ OBSTACLE_NONE = 0,
+ OBSTACLE_XP = 1 << 0,
+ OBSTACLE_XN = 1 << 1,
+ OBSTACLE_ZP = 1 << 2,
+ OBSTACLE_ZN = 1 << 3,
+ OBSTACLE_XP_ZP = 1 << 4,
+ OBSTACLE_XP_ZN = 1 << 5,
+ OBSTACLE_XN_ZP = 1 << 6,
+ OBSTACLE_XN_ZN = 1 << 7
+};
+
+typedef enum BlockType BlockType;
+typedef enum Obstacle Obstacle;
+typedef struct Block Block;
+typedef struct BlockGrid BlockGrid;
+typedef struct GridLocation GridLocation;
+
+struct Block {
+ BlockType type;
const Solid* solid;
-} Block;
+};
-typedef struct {
+struct BlockGrid {
size_t width;
size_t depth;
Block** blocks;
-} BlockGrid;
+};
+
+struct GridLocation {
+ size_t x;
+ size_t z;
+};
-#define BLOCKGRID_CELL_SIZE 2.5f
+static const float BLOCKGRID_CELL_SIZE = 2.5f;
-BlockGrid levelGrid;
+extern BlockGrid levelGrid;
void initLevel();
void startLevel();
-void buildLevelFromImage(TgaImage* image);
+GridLocation gridLocationFromPosition(Vector pos);
+Obstacle getObstacles(GridLocation loc);
static inline Block* getBlockFromGrid(BlockGrid grid, size_t x, size_t z) {
return grid.blocks[(z * grid.width) + x];
grid.blocks[(z * grid.width) + x] = block;
}
-#endif
+static inline float cellBoundaryCoord(size_t cellIndex) {
+ return cellIndex * BLOCKGRID_CELL_SIZE;
+}
+
+#endif // LEVEL_H_