diff --git a/Makefile b/Makefile index 0b8e929aac2d9245f0a0ff871cf8cc0d9a2390af..7473ff4c5895e72857556af202b99ff91cefdf4d 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ SYSTEM := $(shell uname -s) SOURCES := main.c ppm.c keyboard.c mouse.c -GAME := bin/game +GAME := bin/pathfinder HEXDUMP := bin/hexdump PACKER := bin/packer diff --git a/README.md b/README.md index 351c10247498796c3e031e64ca27bd52fe66f211..78bafb98bbbf29982b726f01f705072a68e2f8ee 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,20 @@ ## Aseprite PPM exporter ```sh +# Start from root of the project. mkdir -p ~/.config/aseprite/scripts -ln -s extern/ppm.lua ~/.config/aseprite/scripts/ +ln -s $PWD/extern/ppm.lua ~/.config/aseprite/scripts/ ``` This script can be keybind in Aseprite. + +## Trenchbroom integration + +```sh +# Start from root of the project. +ln -s $PWD/extern/trenchbroom/ ~/.TrenchBroom/games/pathfinder +``` + +- Check that `path` in `GameEngineProfiles.cfg` points to game executable. +- Open Trenchbroom and go to `View>Preferences` and check that `Game Path` + points to project root. diff --git a/extern/trenchbroom/Entities.fgd b/extern/trenchbroom/Entities.fgd new file mode 100644 index 0000000000000000000000000000000000000000..a9191ffd73cd7fa65334e0a4f47eafd8a2e00d03 --- /dev/null +++ b/extern/trenchbroom/Entities.fgd @@ -0,0 +1,25 @@ +@BaseClass = Targetname +[ + targetname(string) : "Name" +] + +@BaseClass = Origin +[ + origin(string) : "Origin" +] + +@SolidClass = worldspawn : "Worldspawn" +[ + message(string) : "Map title" +] + +@PointClass base(Targetname, Origin) size(-16 -16 -16, 16 16 16) = player_start : "Player Start" +[ + angle(integer) : "Angle" : 0 +] + +@PointClass base(Targetname, Origin) size(-8 -8 -8, 8 8 8) = light : "Light" +[ + luminosity(integer) : "Luminosity" : 300 + range(integer) : "Range" : 500 +] diff --git a/extern/trenchbroom/GameConfig.cfg b/extern/trenchbroom/GameConfig.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c8f8e0c60a740c9c380e379bf38c3803a94a0c6b --- /dev/null +++ b/extern/trenchbroom/GameConfig.cfg @@ -0,0 +1,26 @@ +{ + "version": 9, + "name": "Pathfinder", + "icon": "icon.png", + + "fileformats": [ + { "format": "Standard" } + ], + + "filesystem": { + "searchpath": ".", + "packageformat": { "extension": ".pak", "format": "idpak" } + }, + + "materials": { + "root": "textures", + "extensions": [ ".png", ".jpg", ".tga", ".ppm" ] + }, + + "entities": { + "definitions": [ "Entities.fgd" ], + "defaultcolor": "0.6 0.6 0.6 1.0" + }, + + "softMapBounds": "-4096 -4096 -4096 4096 4096 4096" +} diff --git a/extern/trenchbroom/GameEngineProfiles.cfg b/extern/trenchbroom/GameEngineProfiles.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7642d871849df0d1ac04558b955b47e941629630 --- /dev/null +++ b/extern/trenchbroom/GameEngineProfiles.cfg @@ -0,0 +1,10 @@ +{ + "profiles": [ + { + "name": "Pathfinder", + "parameters": "--fps 120 --width 1920 --height 1080 --map maps/${MAP_BASE_NAME}.map", + "path": "/home/m/Projects/pathfinder/tools/tbrun.sh" + } + ], + "version": 1 +} diff --git a/extern/trenchbroom/icon.png b/extern/trenchbroom/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3bf9ef64df136ed6faab099db9d1c1a9f32a3a16 Binary files /dev/null and b/extern/trenchbroom/icon.png differ diff --git a/maps/sandbox.map b/maps/sandbox.map new file mode 100644 index 0000000000000000000000000000000000000000..b7593d43083c2d5d0e37090ed3f3a997f1968e39 --- /dev/null +++ b/maps/sandbox.map @@ -0,0 +1,20 @@ +// Game: Pathfinder +// Format: Standard +// entity 0 +{ +"classname" "worldspawn" +// brush 0 +{ +( -64 -64 -16 ) ( -64 -63 -16 ) ( -64 -64 -15 ) __TB_empty 0 0 0 1 1 +( -64 -64 -16 ) ( -64 -64 -15 ) ( -63 -64 -16 ) __TB_empty 0 0 0 1 1 +( -64 -64 -16 ) ( -63 -64 -16 ) ( -64 -63 -16 ) __TB_empty 0 0 0 1 1 +( 64 64 16 ) ( 64 65 16 ) ( 65 64 16 ) __TB_empty 0 0 0 1 1 +( 64 64 16 ) ( 65 64 16 ) ( 64 64 17 ) __TB_empty 0 0 0 1 1 +( 64 64 16 ) ( 64 64 17 ) ( 64 65 16 ) __TB_empty 0 0 0 1 1 +} +} +// entity 1 +{ +"classname" "player_start" +"origin" "0 0 32" +} diff --git a/tools/tbrun.sh b/tools/tbrun.sh new file mode 100755 index 0000000000000000000000000000000000000000..36da58e7b85e8eb702afd5629d8f6f18582f9d14 --- /dev/null +++ b/tools/tbrun.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +SCRIPT="$0" +case "$SCRIPT" in + /*) ;; + *) SCRIPT="$(pwd)/$SCRIPT" ;; +esac + +# resolve symlinks +while [ -L "$SCRIPT" ]; do + LINK="$(readlink "$SCRIPT")" + case "$LINK" in + /*) SCRIPT="$LINK" ;; + *) SCRIPT="$(dirname "$SCRIPT")/$LINK" ;; + esac +done + +SCRIPT_DIR="$(cd "$(dirname "$SCRIPT")" && pwd -P)" +echo "$SCRIPT_DIR" + +MAP="" +FPS="" +WIDTH="" +HEIGHT="" +while [ $# -gt 0 ]; do + case "$1" in + --map) + shift + MAP="$1" + ;; + --map=*) + MAP="${1#--map=}" + ;; + --fps) + shift + FPS="$1" + ;; + --fps=*) + FPS="${1#--fps=}" + ;; + --width) + shift + WIDTH="$1" + ;; + --width=*) + WIDTH="${1#--width=}" + ;; + --height) + shift + HEIGHT="$1" + ;; + --height=*) + HEIGHT="${1#--height=}" + ;; + --) shift; break;; + *) ;; + esac + shift +done + +cd "$SCRIPT_DIR" +cd .. +DEBUG=1 ./bin/pathfinder --map "$MAP" \ + ${FPS:+--fps "$FPS"} \ + ${WIDTH:+--width "$WIDTH"} \ + ${HEIGHT:+--height "$HEIGHT"}