From 51132aa00ddc4f49bdb1132dc225f56c720e71b8 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Wed, 9 Apr 2025 10:32:36 +0200 Subject: Added new note --- .../notes/2025-04-08-embedding-game-assets-within-your-binary.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'content/notes') diff --git a/content/notes/2025-04-08-embedding-game-assets-within-your-binary.md b/content/notes/2025-04-08-embedding-game-assets-within-your-binary.md index bb709bb..65f5813 100644 --- a/content/notes/2025-04-08-embedding-game-assets-within-your-binary.md +++ b/content/notes/2025-04-08-embedding-game-assets-within-your-binary.md @@ -93,7 +93,7 @@ CC ?= cc CFLAGS := -Wall -Wextra -Wunused -Wno-unused-parameter -Wswitch-enum -Wpedantic -Wno-bitwise-instead-of-logical LDFLAGS := -I./libs -I./libs/raylib-$(RAYLIB_VER)/include ./libs/raylib-$(RAYLIB_VER)/lib/libraylib.a -lm -game: +game: embed $(CC) $(CFLAGS) -o game main.c $(LDFLAGS) embed: @@ -105,6 +105,9 @@ This converted binary data files into C header style files which contain the array of bytes and the size of the array of bytes. This will be useful later with raylib code. +If we execute `make embed` we will create C header files. But running `make +game` will also call embed as well, so no need to call it separately. + An example of such a file (in our case armor.png) looks like this. ```c @@ -190,6 +193,8 @@ get quite big and if that is the problem, you could always compile this into a `so` library and include that. This way you could create data packs for audio, graphics, etc. and ship that alongside your game binary. +Run `make -B game` and run the game. + ![Basic window](/assets/notes/embedding-assets.png) ## Honorable mention: C23-embed-directive -- cgit v1.2.3