A game engine for top-down 2D RPG games.
rpg game-engine raylib c99

refactor scripts and add tile selection indicator

+9
run.sh
··· 1 + #!/usr/bin/env sh 2 + set -e 3 + 4 + for s in "$@" 5 + do 6 + echo "-> $s" 7 + sh scripts/$s.sh 8 + echo "-> done" 9 + done
+5
scripts/_config.sh
··· 1 + #!/usr/bin/env sh 2 + set -e 3 + 4 + export CFLAGS="-Wall -Wextra -Werror -std=c99 -Iinclude/ -c" 5 + export LFLAGS="-lraylib -lm -lGL -lpthread -ldl -lrt -lX11"
+12
scripts/build-prod.sh
··· 1 + #!/usr/bin/env sh 2 + set -e 3 + 4 + . scripts/_config.sh 5 + 6 + export CFLAGS="$CFLAGS -O3" 7 + export LFLAGS="$LFLAGS -O3" 8 + 9 + sh scripts/functions/init.sh 10 + sh scripts/functions/compile.sh 11 + sh scripts/functions/link.sh 12 + sh scripts/functions/cleanup.sh
+5 -18
scripts/build.sh
··· 1 1 #!/usr/bin/env sh 2 2 set -e 3 - . scripts/_config.sh 4 3 5 - mkdir -p build/ 6 - 7 - if [ -e "build/keraforge" ] 8 - then 9 - rm build/keraforge 10 - fi 4 + . scripts/_config.sh 11 5 12 - echo ": building" 13 - for f in `find src/ -name '*.c'` 14 - do 15 - ff=$(echo "$f" | tr '/' '_') 16 - gcc -Wall -Wextra -Werror -std=c99 -Iinclude/ -c $f -o build/${ff%.c}.o 17 - done 18 - 19 - echo ": linking" 20 - gcc -lraylib -lm -lGL -lpthread -ldl -lrt -lX11 build/*.o -o build/keraforge 21 - 22 - rm build/*.o 6 + sh scripts/functions/init.sh 7 + sh scripts/functions/compile.sh 8 + sh scripts/functions/link.sh 9 + sh scripts/functions/cleanup.sh
+7
scripts/clean.sh
··· 1 + #!/usr/bin/env sh 2 + set -e 3 + 4 + if [ -e "build" ] 5 + then 6 + rm -rf build 7 + fi
+5
scripts/functions/cleanup.sh
··· 1 + #!/usr/bin/env sh 2 + set -e 3 + 4 + echo ": cleaning up" 5 + rm build/*.o
+10
scripts/functions/compile.sh
··· 1 + #!/usr/bin/env sh 2 + set -e 3 + 4 + echo ": compiling" 5 + for f in `find src/ -name '*.c'` 6 + do 7 + ff=$(echo "$f" | tr '/' '_') 8 + gcc $CFLAGS $f -o build/${ff%.c}.o 9 + done 10 +
+9
scripts/functions/init.sh
··· 1 + #!/usr/bin/env sh 2 + set -e 3 + 4 + mkdir -p build/ 5 + 6 + if [ -e "build/keraforge" ] 7 + then 8 + rm build/keraforge 9 + fi
+5
scripts/functions/link.sh
··· 1 + #!/usr/bin/env sh 2 + set -e 3 + 4 + echo ": linking" 5 + gcc -o build/keraforge build/*.o $LFLAGS
+10
scripts/run.sh
··· 1 + #!/usr/bin/env sh 2 + set -e 3 + 4 + if [ -e "./build/keraforge" ] 5 + then 6 + ./build/keraforge 7 + else 8 + echo ": error: no build available" 9 + exit 1 10 + fi
+7
src/main.c
··· 9 9 10 10 static Camera2D cam; 11 11 static f32 dt = 0; 12 + static struct kf_vec2(u32) select = { 0, 0 }; 12 13 13 14 static void _player_tick(struct kf_world *world, struct kf_actor *self) 14 15 { ··· 114 115 { 115 116 player->tick(world, player); 116 117 118 + Vector2 v = GetScreenToWorld2D(GetMousePosition(), cam); 119 + select.x = v.x / KF_TILE_SIZE_PX; 120 + select.y = v.y / KF_TILE_SIZE_PX; 121 + 117 122 BeginDrawing(); 118 123 ClearBackground(WHITE); 119 124 120 125 BeginMode2D(cam); 121 126 kf_world_draw(world, cam); 127 + if (select.x < world->width && select.y < world->height) 128 + DrawRectangleLines(select.x * KF_TILE_SIZE_PX, select.y * KF_TILE_SIZE_PX, KF_TILE_SIZE_PX, KF_TILE_SIZE_PX, WHITE); 122 129 player->draw(world, player); 123 130 EndMode2D(); 124 131