]> git.lizzy.rs Git - shadowclad.git/blobdiff - src/game/level.c
A bit of cleanup
[shadowclad.git] / src / game / level.c
index 2b45eecdc2839a9dbb480e79ffea548b4f3e428b..fd7f8ac548a475aceb0c8f950bf5d4d03d249f94 100644 (file)
@@ -5,11 +5,14 @@
 
 #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,
@@ -17,6 +20,10 @@ 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() {
@@ -49,7 +56,7 @@ void startLevel() {
        spawnPlayer(playerSpawnTransform);
 }
 
-void buildLevelFromImage(TgaImage* image) {
+static void buildLevelFromImage(const TgaImage* image) {
        if (image == NULL) {
                logError("Null image received, cannot build level");
                return;
@@ -94,3 +101,11 @@ void buildLevelFromImage(TgaImage* image) {
        
        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;
+}