Skip to content

Commit

Permalink
replace header guards with more portable ones
Browse files Browse the repository at this point in the history
  • Loading branch information
MESYETI committed Aug 28, 2022
1 parent 30a0791 commit 3918eb6
Show file tree
Hide file tree
Showing 21 changed files with 100 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CXXFLAGS = \
-Wall \
-Wextra \
-pedantic \
-g \
-g -lm \
-Wno-deprecated-declarations

ifeq (${platform}, windows)
Expand Down
5 changes: 4 additions & 1 deletion src/_components.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#ifndef YCRAFT__COMPONENTS_HH
#define YCRAFT__COMPONENTS_HH

// macros
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
Expand Down Expand Up @@ -41,3 +42,5 @@
typedef uint16_t blockID_t;
typedef uint16_t itemID_t;
typedef uint32_t textureID_t;

#endif
6 changes: 5 additions & 1 deletion src/animation.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_ANIMATION_HH
#define YCRAFT_ANIMATION_HH

#include "_components.hh"

class Animation {
Expand All @@ -10,3 +12,5 @@ class Animation {
void NextFrame();
textureID_t GetFrame();
};

#endif
6 changes: 5 additions & 1 deletion src/app.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_APP_HH
#define YCRAFT_APP_HH

#include "_components.hh"
#include "video.hh"
#include "text.hh"
Expand Down Expand Up @@ -40,3 +42,5 @@ class App {
void Update();
void Render();
};

#endif
6 changes: 5 additions & 1 deletion src/blockdefs.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_BLOCKDEFS_HH
#define YCRAFT_BLOCKDEFS_HH

#include "_components.hh"

enum class BlockType {
Expand All @@ -25,3 +27,5 @@ class Blockdefs {
blockID_t id, std::string name, uint32_t textureID, BlockType type
);
};

#endif
6 changes: 5 additions & 1 deletion src/collision.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_COLLISION_HH
#define YCRAFT_COLLISION_HH

#include "_components.hh"
#include "types.hh"
#include "level.hh"
Expand All @@ -18,3 +20,5 @@ namespace Collision {
float& time, const FVec2& vel
);
}

#endif
5 changes: 4 additions & 1 deletion src/constants.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#ifndef YCRAFT_CONSTANTS_HH
#define YCRAFT_CONSTANTS_HH

#define APP_NAME "ycraft"
#define APP_VERSION "demo 0.0.1"
Expand All @@ -9,3 +10,5 @@
#define GAME_BLOCK_SIZE 16
#define GAME_PLAYER_SPEED 1.0
#define GAME_PLAYER_FAST_SPEED 2.0

#endif
6 changes: 5 additions & 1 deletion src/game.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_GAME_HH
#define YCRAFT_GAME_HH

#include "_components.hh"
#include "blockdefs.hh"
#include "types.hh"
Expand Down Expand Up @@ -30,3 +32,5 @@ class Game {
void PlaceBlock();
void DeleteBlock();
};

#endif
6 changes: 5 additions & 1 deletion src/image.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_IMAGE_HH
#define YCRAFT_IMAGE_HH

#include "_components.hh"

class ImageComponents {
Expand All @@ -8,3 +10,5 @@ class ImageComponents {
void Init();
void Free();
};

#endif
6 changes: 5 additions & 1 deletion src/inventory.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_INVENTORY_HH
#define YCRAFT_INVENTORY_HH

#include "_components.hh"

struct InventoryEntry {
Expand All @@ -16,3 +18,5 @@ class Inventory {
// functions
Inventory();
};

#endif
6 changes: 5 additions & 1 deletion src/level.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_LEVEL_HH
#define YCRAFT_LEVEL_HH

#include "_components.hh"
#include "types.hh"

Expand All @@ -17,3 +19,5 @@ class Level {
Level() {}
void Generate(UVec2 p_size);
};

#endif
10 changes: 7 additions & 3 deletions src/light.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_LIGHT_HH
#define YCRAFT_LIGHT_HH

#include "_components.hh"
#include "types.hh"

Expand All @@ -9,6 +11,8 @@ typedef uint8_t lightLevel_t;
class LevelLight {
public:
// variables
lightLevel_t globalLightLevel;

lightLevel_t globalLightLevel;
std::vector <std::vector <lightLevel_t>> light;
};

#endif
6 changes: 5 additions & 1 deletion src/player.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_PLAYER_HH
#define YCRAFT_PLAYER_HH

#include "_components.hh"
#include "types.hh"
#include "level.hh"
Expand Down Expand Up @@ -37,3 +39,5 @@ class Player {
textureID_t GetTextureID();
FVec2 CorrectPosition();
};

#endif
6 changes: 5 additions & 1 deletion src/text.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_TEXT_HH
#define YCRAFT_TEXT_HH

#include "_components.hh"
#include "video.hh"
#include "types.hh"
Expand All @@ -18,3 +20,5 @@ class TextComponents {
);
Vec2 GetTextSize(std::string text, float size);
};

#endif
6 changes: 5 additions & 1 deletion src/tiles.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_TILES_HH
#define YCRAFT_TILES_HH

#include "_components.hh"
#include "types.hh"

Expand All @@ -15,3 +17,5 @@ class TileSheet {
UVec2 GetTexturePosition(uint32_t id);
void RenderTile(SDL_Renderer* renderer, uint32_t id, Vec2 pos);
};

#endif
6 changes: 5 additions & 1 deletion src/titleScreen.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_TITLESCREEN_HH
#define YCRAFT_TITLESCREEN_HH

#include "_components.hh"
#include "ui.hh"

Expand All @@ -20,3 +22,5 @@ namespace Menus {
void Render(SDL_Renderer* renderer, TextComponents& text);
};
}

#endif
6 changes: 5 additions & 1 deletion src/types.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_TYPES_HH
#define YCRAFT_TYPES_HH

#include "_components.hh"

struct Vec2 {
Expand All @@ -22,3 +24,5 @@ typedef SDL_Rect Rect;
struct FRect { // float Rect
float x, y, w, h;
};

#endif
6 changes: 5 additions & 1 deletion src/ui.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_UI_HH
#define YCRAFT_UI_HH

#include "_components.hh"
#include "types.hh"
#include "text.hh"
Expand Down Expand Up @@ -28,3 +30,5 @@ namespace UI {
void Render(SDL_Renderer* renderer, TextComponents& text);
};
}

#endif
6 changes: 5 additions & 1 deletion src/util.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_UTIL_HH
#define YCRAFT_UTIL_HH

#include "_components.hh"

namespace Util {
Expand All @@ -8,3 +10,5 @@ namespace Util {
std::string DirName(std::string path);
double Clamp(double x, double min, double max);
}

#endif
6 changes: 5 additions & 1 deletion src/video.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef YCRAFT_VIDEO_HH
#define YCRAFT_VIDEO_HH

#include "_components.hh"

class VideoComponents {
Expand All @@ -12,3 +14,5 @@ class VideoComponents {
void Init();
void Free();
};

#endif
5 changes: 4 additions & 1 deletion src/worldMenu.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#ifndef YCRAFT_WORLDMENU_HH
#define YCRAFT_WORLDMENU_HH
#include "_components.hh"
#include "text.hh"
#include "ui.hh"
Expand All @@ -21,3 +22,5 @@ namespace Menus {
void Render(SDL_Renderer* renderer, TextComponents& text);
};
}

#endif

0 comments on commit 3918eb6

Please sign in to comment.