#include "engine/logger.h"
#include "engine/scene.h"
+#include "engine/tga.h"
#include "player.h"
BlockGrid levelGrid;
+static const float BLOCKGRID_CELL_SIZE = 2.5f;
+
static Block blockEmpty = { .type = BLOCKTYPE_SPACE,
.solid = NULL };
static Block blockWall01 = { .type = BLOCKTYPE_OBSTACLE,
static Transform playerSpawnTransform;
+static void buildLevelFromImage(const TgaImage* image);
+static inline Block* getBlockFromGrid(BlockGrid grid, size_t x, size_t z);
+static inline void setBlockInGrid(BlockGrid grid, size_t x, size_t z, Block* block);
+
void initLevel() {
spawnPlayer(playerSpawnTransform);
}
-void buildLevelFromImage(TgaImage* image) {
+static void buildLevelFromImage(const TgaImage* image) {
if (image == NULL) {
logError("Null image received, cannot build level");
return;
levelGrid = newGrid;
}
+
+static inline Block* getBlockFromGrid(BlockGrid grid, size_t x, size_t z) {
+ return grid.blocks[(z * grid.width) + x];
+}
+
+static inline void setBlockInGrid(BlockGrid grid, size_t x, size_t z, Block* block) {
+ grid.blocks[(z * grid.width) + x] = block;
+}
#include <stdint.h>
#include "engine/asset.h"
-#include "engine/tga.h"
-typedef enum {
+enum BlockType {
BLOCKTYPE_SPACE,
BLOCKTYPE_OBSTACLE_X,
BLOCKTYPE_OBSTACLE_Z,
BLOCKTYPE_OBSTACLE
-} BlockType;
+};
-typedef struct {
- const BlockType type;
+typedef enum BlockType BlockType;
+typedef struct Block Block;
+typedef struct BlockGrid BlockGrid;
+
+struct Block {
+ BlockType type;
const Solid* solid;
-} Block;
+};
-typedef struct {
+struct BlockGrid {
size_t width;
size_t depth;
Block** blocks;
-} BlockGrid;
-
-#define BLOCKGRID_CELL_SIZE 2.5f
+};
extern BlockGrid levelGrid;
void initLevel();
void startLevel();
-void buildLevelFromImage(TgaImage* image);
-
-static inline Block* getBlockFromGrid(BlockGrid grid, size_t x, size_t z) {
- return grid.blocks[(z * grid.width) + x];
-}
-
-static inline void setBlockInGrid(BlockGrid grid, size_t x, size_t z, Block* block) {
- grid.blocks[(z * grid.width) + x] = block;
-}
#endif // LEVEL_H_