From 7abbf8459df5ebe80bb66b7a6a6b00a08b218945 Mon Sep 17 00:00:00 2001 From: Gabriel Pariat Date: Sat, 18 Feb 2023 20:42:43 -0500 Subject: [PATCH] tweak to makefile and reorganization to my standards --- .gitmodules | 3 +++ src/Makefile => Makefile | 33 ++++++++++++++++------- lib/raylib | 1 + {src/resources => resources}/LICENSE | 0 {src/resources => resources}/ambient.ogg | Bin {src/resources => resources}/coin.wav | Bin {src/resources => resources}/mecha.png | Bin src/screen_title.c | 4 +-- 8 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 .gitmodules rename src/Makefile => Makefile (94%) create mode 160000 lib/raylib rename {src/resources => resources}/LICENSE (100%) rename {src/resources => resources}/ambient.ogg (100%) rename {src/resources => resources}/coin.wav (100%) rename {src/resources => resources}/mecha.png (100%) diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..c2b2ff7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/raylib"] + path = lib/raylib + url = https://github.com/raysan5/raylib.git diff --git a/src/Makefile b/Makefile similarity index 94% rename from src/Makefile rename to Makefile index 657da15..009cf19 100644 --- a/src/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ # #************************************************************************************************** -.PHONY: all clean +.PHONY: all clean run # Define required environment variables #------------------------------------------------------------------------------------------------ @@ -29,11 +29,11 @@ PLATFORM ?= PLATFORM_DESKTOP # Define project variables -PROJECT_NAME ?= raylib_game +PROJECT_NAME ?= lemonade-stand PROJECT_VERSION ?= 1.0 PROJECT_BUILD_PATH ?= . -RAYLIB_PATH ?= ../../raylib +RAYLIB_PATH ?= ./lib/raylib # Locations of raylib.h and libraylib.a/libraylib.so # NOTE: Those variables are only used for PLATFORM_OS: LINUX, BSD @@ -57,6 +57,10 @@ BUILD_WEB_HEAP_SIZE ?= 134217728 BUILD_WEB_RESOURCES ?= TRUE BUILD_WEB_RESOURCES_PATH ?= resources +BUILD_DIR ?= ./build +SRC_DIR ?= ./src +LIB_DIR ?= ./lib + # Use cross-compiler for PLATFORM_RPI ifeq ($(PLATFORM),PLATFORM_RPI) USE_RPI_CROSS_COMPILER ?= FALSE @@ -230,7 +234,7 @@ endif # Define include paths for required headers: INCLUDE_PATHS # NOTE: Some external/extras libraries could be required (stb, physac, easings...) #------------------------------------------------------------------------------------------------ -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external -I$(RAYLIB_PATH)/src/extras +INCLUDE_PATHS = -I$(SRC_DIR) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external -I$(RAYLIB_PATH)/src/extras # Define additional directories containing required header files ifeq ($(PLATFORM),PLATFORM_DESKTOP) @@ -252,7 +256,7 @@ endif # Define library paths containing required libs: LDFLAGS #------------------------------------------------------------------------------------------------ -LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src +LDFLAGS = -L$(SRC) -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) @@ -383,7 +387,9 @@ PROJECT_SOURCE_FILES ?= \ screen_ending.c # Define all object files from source files -OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES)) +OBJS = $(addprefix $(BUILD_DIR)/,$(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES))) +# +SOURCE_FILES = $(addprefix $(SRC_DIR)/,$(PROJECT_SOURCE_FILES)) # Define processes to execute @@ -394,7 +400,7 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID) export PROJECT_NAME export PROJECT_SOURCE_FILES else - MAKEFILE_PARAMS = $(PROJECT_NAME) + MAKEFILE_PARAMS = $(BUILD_DIR)/$(PROJECT_NAME) endif # Default target entry @@ -403,12 +409,12 @@ all: $(MAKE) $(MAKEFILE_PARAMS) # Project target defined by PROJECT_NAME -$(PROJECT_NAME): $(OBJS) - $(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) +$(BUILD_DIR)/$(PROJECT_NAME): $(OBJS) + $(CC) -o $@$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) # Compile source files # NOTE: This pattern will compile every module defined on $(OBJS) -%.o: %.c +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) # Clean everything @@ -436,3 +442,10 @@ ifeq ($(PLATFORM),PLATFORM_DRM) endif @echo Cleaning done +run: $(PROJECT_NAME)$(EXT) +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ./$(PROJECT_NAME) +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + npx live-server --open=$(PROJECT_NAME)$(EXT) --ignore=*.c,*.h,Makefile +endif diff --git a/lib/raylib b/lib/raylib new file mode 160000 index 0000000..47dd842 --- /dev/null +++ b/lib/raylib @@ -0,0 +1 @@ +Subproject commit 47dd842e8163d43587c7f6bb91bbf88dbdbb24b1 diff --git a/src/resources/LICENSE b/resources/LICENSE similarity index 100% rename from src/resources/LICENSE rename to resources/LICENSE diff --git a/src/resources/ambient.ogg b/resources/ambient.ogg similarity index 100% rename from src/resources/ambient.ogg rename to resources/ambient.ogg diff --git a/src/resources/coin.wav b/resources/coin.wav similarity index 100% rename from src/resources/coin.wav rename to resources/coin.wav diff --git a/src/resources/mecha.png b/resources/mecha.png similarity index 100% rename from src/resources/mecha.png rename to resources/mecha.png diff --git a/src/screen_title.c b/src/screen_title.c index 409fc7f..4644261 100644 --- a/src/screen_title.c +++ b/src/screen_title.c @@ -64,7 +64,7 @@ void DrawTitleScreen(void) // TODO: Draw TITLE screen here! DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GREEN); Vector2 pos = { 20, 10 }; - DrawTextEx(font, "TITLE SCREEN", pos, font.baseSize*3.0f, 4, DARKGREEN); + DrawTextEx(font, "Lemonade Stand", pos, font.baseSize*3.0f, 4, DARKGREEN); DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, DARKGREEN); } @@ -78,4 +78,4 @@ void UnloadTitleScreen(void) int FinishTitleScreen(void) { return finishScreen; -} \ No newline at end of file +}