Split debug flags out of CFLAGS and drop unused lib.h macros
This commit is contained in:
parent
65aafd0052
commit
7e1748d3b4
9
Makefile
9
Makefile
@ -1,17 +1,18 @@
|
|||||||
CFLAGS=-g --std=c++23 -fsanitize=address -fno-omit-frame-pointer -Wall -Wextra -pedantic -O0
|
CFLAGS=--std=c++23 -Wall -Wextra -pedantic -O0 -DDEBUG
|
||||||
|
DEBUGFLAGS=-g3 -gdwarf-4 -fsanitize=address -fno-omit-frame-pointer -DDEBUG
|
||||||
LDFLAGS=-L./lib -lraylib -lm -ldl
|
LDFLAGS=-L./lib -lraylib -lm -ldl
|
||||||
INCLUDES=-I./include
|
INCLUDES=-I./include
|
||||||
CC=g++
|
CC=g++
|
||||||
|
|
||||||
.PHONY: build clean run all
|
.PHONY: build clean run all
|
||||||
|
|
||||||
all: main game.so
|
all: game.so main
|
||||||
|
|
||||||
main: main.cpp game.h Makefile
|
main: main.cpp game.h Makefile
|
||||||
$(CC) $(CFLAGS) $(INCLUDES) main.cpp $(LDFLAGS) -o main
|
$(CC) $(CFLAGS) $(INCLUDES) $(DEBUGFLAGS) main.cpp $(LDFLAGS) -o main
|
||||||
|
|
||||||
game.so: game.cpp game.h lib.h sprites.h game_data.h Makefile
|
game.so: game.cpp game.h lib.h sprites.h game_data.h Makefile
|
||||||
$(CC) $(CFLAGS) $(INCLUDES) -shared -fPIC game.cpp -L./lib -lraylib -lm -o game.so.tmp
|
$(CC) $(CFLAGS) $(INCLUDES) $(DEBUGFLAGS) -shared -fPIC game.cpp -L./lib -lraylib -lm -o game.so.tmp
|
||||||
mv game.so.tmp game.so
|
mv game.so.tmp game.so
|
||||||
|
|
||||||
run: all
|
run: all
|
||||||
|
|||||||
4
game.cpp
4
game.cpp
@ -54,7 +54,7 @@ GameState *InitState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GameState *Init() {
|
GameState *Init() {
|
||||||
SetTraceLogLevel(4);
|
SetTraceLogLevel(LOG_WARNING);
|
||||||
InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "Tiny Knights");
|
InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "Tiny Knights");
|
||||||
|
|
||||||
int monitor = GetCurrentMonitor();
|
int monitor = GetCurrentMonitor();
|
||||||
@ -229,7 +229,7 @@ void Draw2D(GameState *state) {
|
|||||||
}
|
}
|
||||||
Vector2 pos = {(f32)(32 * col + topx), (f32)(32 * row + topy)};
|
Vector2 pos = {(f32)(32 * col + topx), (f32)(32 * row + topy)};
|
||||||
Rectangle src_rect = {(f32)(32 * atlas_col), (f32)(32 * atlas_row), 32, 32};
|
Rectangle src_rect = {(f32)(32 * atlas_col), (f32)(32 * atlas_row), 32, 32};
|
||||||
D_DrawTextureRec(state->assets.textures[TEX_GROUND], src_rect, pos, WHITE);
|
DrawTextureRec(state->assets.textures[TEX_GROUND], src_rect, pos, WHITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
game.h
2
game.h
@ -14,8 +14,6 @@ using namespace std;
|
|||||||
#define SCREEN_WIDTH 1300
|
#define SCREEN_WIDTH 1300
|
||||||
#define SCREEN_HEIGHT 1080
|
#define SCREEN_HEIGHT 1080
|
||||||
|
|
||||||
#define DEBUG_MODE_ENABLED
|
|
||||||
|
|
||||||
bool global_debug_mode = false;
|
bool global_debug_mode = false;
|
||||||
|
|
||||||
enum class KnightState {
|
enum class KnightState {
|
||||||
|
|||||||
34
lib.h
34
lib.h
@ -17,7 +17,6 @@ typedef float f32;
|
|||||||
typedef double f64;
|
typedef double f64;
|
||||||
typedef uintptr_t uptr;
|
typedef uintptr_t uptr;
|
||||||
typedef char sbyte;
|
typedef char sbyte;
|
||||||
typedef ptrdiff_t size;
|
|
||||||
typedef size_t usize;
|
typedef size_t usize;
|
||||||
|
|
||||||
typedef Vector2 Point;
|
typedef Vector2 Point;
|
||||||
@ -48,7 +47,7 @@ extern "C" {
|
|||||||
extern bool global_debug_mode;
|
extern bool global_debug_mode;
|
||||||
inline void D_DrawTextureV(Texture2D texture, Vector2 position, Color tint) {
|
inline void D_DrawTextureV(Texture2D texture, Vector2 position, Color tint) {
|
||||||
DrawTextureV(texture, position, tint);
|
DrawTextureV(texture, position, tint);
|
||||||
#ifdef DEBUG_MODE_ENABLED
|
#ifdef DEBUG
|
||||||
if (global_debug_mode) {
|
if (global_debug_mode) {
|
||||||
Rectangle debug = {position.x,position.y,(f32)texture.width,(f32)texture.height};
|
Rectangle debug = {position.x,position.y,(f32)texture.width,(f32)texture.height};
|
||||||
DrawRectangleLinesEx(debug, 1.0f, RED);
|
DrawRectangleLinesEx(debug, 1.0f, RED);
|
||||||
@ -56,37 +55,10 @@ inline void D_DrawTextureV(Texture2D texture, Vector2 position, Color tint) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vector2 operations
|
|
||||||
#define v2_add Vector2Add
|
|
||||||
#define v2_sub Vector2Subtract
|
|
||||||
#define v2_mul Vector2Scale
|
|
||||||
#define v2_div Vector2Divide
|
|
||||||
#define v2_dot Vector2DotProduct
|
|
||||||
#define v2_len Vector2Length
|
|
||||||
#define v2_norm Vector2Normalize
|
|
||||||
#define v2_dist Vector2Distance
|
|
||||||
#define v2_lerp Vector2Lerp
|
|
||||||
|
|
||||||
// Vector3 operations
|
|
||||||
#define v3_add Vector3Add
|
|
||||||
#define v3_sub Vector3Subtract
|
|
||||||
#define v3_mul Vector3Scale
|
|
||||||
#define v3_div Vector3Divide
|
|
||||||
#define v3_dot Vector3DotProduct
|
|
||||||
#define v3_cross Vector3CrossProduct
|
|
||||||
#define v3_len Vector3Length
|
|
||||||
#define v3_norm Vector3Normalize
|
|
||||||
#define v3_dist Vector3Distance
|
|
||||||
#define v3_lerp Vector3Lerp
|
|
||||||
|
|
||||||
// Constructor-style macros
|
|
||||||
#define v2(x, y) ((Vector2){x, y})
|
|
||||||
#define v3(x, y, z) ((Vector3){x, y, z})
|
|
||||||
|
|
||||||
|
|
||||||
inline void D_DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint) {
|
inline void D_DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint) {
|
||||||
DrawTextureRec(texture, source, position, tint);
|
DrawTextureRec(texture, source, position, tint);
|
||||||
#ifdef DEBUG_MODE_ENABLED
|
#ifdef DEBUG
|
||||||
if (global_debug_mode) {
|
if (global_debug_mode) {
|
||||||
Rectangle debug = {position.x,position.y,source.width,source.height};
|
Rectangle debug = {position.x,position.y,source.width,source.height};
|
||||||
DrawRectangleLinesEx(debug, 1.0f, RED);
|
DrawRectangleLinesEx(debug, 1.0f, RED);
|
||||||
@ -96,7 +68,7 @@ inline void D_DrawTextureRec(Texture2D texture, Rectangle source, Vector2 positi
|
|||||||
|
|
||||||
inline void D_DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint) {
|
inline void D_DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint) {
|
||||||
DrawTexturePro(texture, source, dest, origin, rotation, tint);
|
DrawTexturePro(texture, source, dest, origin, rotation, tint);
|
||||||
#ifdef DEBUG_MODE_ENABLED
|
#ifdef DEBUG
|
||||||
if (global_debug_mode) {
|
if (global_debug_mode) {
|
||||||
Rectangle debug = {dest.x-origin.x,dest.y-origin.y,dest.width,dest.height};
|
Rectangle debug = {dest.x-origin.x,dest.y-origin.y,dest.width,dest.height};
|
||||||
DrawRectangleLinesEx(debug, 1.0f, RED);
|
DrawRectangleLinesEx(debug, 1.0f, RED);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user