]> git.lizzy.rs Git - shadowclad.git/commitdiff
A bit of cleanup
authoroutfrost <kotlet.bahn@gmail.com>
Tue, 14 Jul 2020 21:46:16 +0000 (23:46 +0200)
committeroutfrost <kotlet.bahn@gmail.com>
Tue, 14 Jul 2020 21:46:16 +0000 (23:46 +0200)
src/engine/logger.h
src/engine/tga.h
src/game/level.c
src/game/level.h

index 4529738e77a15dd5e9bd50a3bc557e2a04824058..c6dc80825e80d1f16301e9f63071c445c1d995c9 100644 (file)
@@ -1,12 +1,14 @@
 #ifndef ENGINE_LOGGER_H_
 #define ENGINE_LOGGER_H_
 
-typedef enum {
+enum LogLevel {
        LOGLEVEL_ERROR,
        LOGLEVEL_WARNING,
        LOGLEVEL_INFO,
        LOGLEVEL_DEBUG
-} LogLevel;
+};
+
+typedef enum LogLevel LogLevel;
 
 extern LogLevel logLevel;
 
index 0936fa81aa7211baabf75dbb00cbaf6650522bec..01e9ca88c10664c29f8b472f0573348799b8bd96 100644 (file)
@@ -3,8 +3,11 @@
 
 #include <GL/gl.h>
 
+typedef struct TgaHeader TgaHeader;
+typedef struct TgaImage TgaImage;
+
 #pragma pack(push, 1)
-typedef struct {
+struct TgaHeader {
        GLubyte idLength;
        GLbyte colorMapType;
        GLbyte imageType;
@@ -17,15 +20,15 @@ typedef struct {
        GLushort imageHeight;
        GLubyte imageBpp;
        GLbyte imageDescriptor;
-} TgaHeader;
+};
 #pragma pack(pop)
 
-typedef struct {
+struct TgaImage {
        TgaHeader header;
        GLenum imageFormat;
        GLint imageComponents;
        GLbyte* bytes;
-} TgaImage;
+};
 
 TgaImage* readTga(const char* path);
 
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;
+}
index 4d6992ede5631eabcc79fb5190732e1ea75194d7..097b73acdda82744d0ae81ef70f4d1f43b384292 100644 (file)
@@ -4,40 +4,32 @@
 #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_