Commit b4b60a98 authored by Delisa Mason's avatar Delisa Mason

feat: Add Tiled command to run the game after exporting

parent b83a0e73
all: build
.PHONY: build add-map add-state add-system help test
TILED:=~/bin/apps/Tiled.app/Contents/MacOS/Tiled
LOVE:=/usr/local/bin/love
.PHONY: run build add-map add-state add-system help test tiled-run tiled-edit-hooks
run: build
build: ## Build and run the project
@love .
@$(LOVE) .
help: ## Show help text
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
......@@ -66,3 +71,21 @@ endif
filepath=game/assets/maps/$${level}/$${objname}.lua; \
test -f $${filepath} || $(MAKE) add-hooks name=$${objname} level=$${level}; \
mvim game/assets/maps/$${level}/$${objname}.lua;
# Companion to a Tiled command which runs the game after exporting the map
# which is currently being edited.
#
# Tiled command:
# * Executable: `make tiled-run mapfile=%mapfile`
# * Working directory: %mappath/../../..
tiled-run: ## Run game after exporting a map
ifeq ($(mapfile),) # %mapfile
@$(error mapfile is not defined. Run with `make tiled-run mapfile=[value]`)
endif
@mapfilename=$(shell basename $(mapfile)); \
dir=$${mapfilename%.*}; \
exportdir=game/assets/maps/$${dir}; \
exportfile=$${exportdir}/init.lua; \
mkdir -p $${exportdir}; \
$(TILED) --export-map lua "$(mapfile)" "$${exportfile}"; \
$(MAKE) run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment