modules = \
  modules/dom/canvas.scm \
  modules/dom/document.scm \
  modules/dom/element.scm \
  modules/dom/event.scm \
  modules/dom/image.scm \
  modules/dom/media.scm \
  modules/dom/window.scm \
  modules/game/actors.scm \
  modules/game/effects.scm \
  modules/game/level.scm \
  modules/game/tileset.scm \
  modules/goblins/abstract-types.scm \
  modules/goblins/core.scm \
  modules/goblins/core-types.scm \
  modules/goblins/ghash.scm \
  modules/guile/list.scm \
  modules/ice-9/control.scm \
  modules/ice-9/q.scm \
  modules/ice-9/vlist.scm \
  modules/local-storage.scm \
  modules/math.scm \
  modules/math/rect.scm \
  modules/math/vector.scm \
  modules/srfi/srfi-9.scm \
  modules/srfi/srfi-11.scm

levels = \
  modules/game/levels/level-1.scm \
  modules/game/levels/level-2.scm \
  modules/game/levels/level-3.scm \
  modules/game/levels/level-4.scm \
  modules/game/levels/credits.scm

game.wasm: game.scm $(modules) $(levels)
	guild compile-wasm -L modules -o $@ $<

$(levels): %.scm: %.tmx scripts/compile-map.scm
	mkdir -p modules/game/levels
	guile scripts/compile-map.scm $< > $@

serve: game.wasm
	guile -c '((@ (hoot web-server) serve))'

bundle: game.wasm
	rm cirkoban.zip || true
	zip cirkoban.zip -r assets/ reflect.js game.js game.css reflect.wasm wtf8.wasm game.wasm index.html

clean:
	rm -f game.wasm game.zip $(levels)
