~bigbes/game-prototype-ftl

2cb11babde8944242d1ca99dd6e03d91a994f1ed — Eugene Blikh a month ago 232ad03
add Makefile, WASM loader shell, play-web target
3 files changed, 47 insertions(+), 0 deletions(-)

A .gitignore
A Makefile
A web/index.html
A .gitignore => .gitignore +4 -0
@@ 0,0 1,4 @@
bin/
web/main.wasm
web/wasm_exec.js
/ftl-shape

A Makefile => Makefile +26 -0
@@ 0,0 1,26 @@
.PHONY: run build build-wasm serve play-web

run:
	go run .

build:
	@mkdir -p bin
	go build -o bin/ftl-shape .

build-wasm:
	@mkdir -p web
	GOOS=js GOARCH=wasm go build -o web/main.wasm .
	cp "$$(go env GOROOT)/lib/wasm/wasm_exec.js" web/wasm_exec.js

serve:
	go run github.com/hajimehoshi/wasmserve@latest .

play-web:
	@mkdir -p web
	@case "$$(uname -s)" in \
	  Darwin) OPEN_CMD=open ;; \
	  Linux)  OPEN_CMD=xdg-open ;; \
	  *)      OPEN_CMD=: ;; \
	esac; \
	( sleep 1 && $$OPEN_CMD http://localhost:8080 ) & \
	go run github.com/hajimehoshi/wasmserve@latest .

A web/index.html => web/index.html +17 -0
@@ 0,0 1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>ftl-shape</title>
  <style>body { margin: 0; background: #000; } canvas { display: block; margin: 0 auto; }</style>
</head>
<body>
  <canvas id="ebiten" width="1280" height="720"></canvas>
  <script src="wasm_exec.js"></script>
  <script>
    const go = new Go();
    WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject)
      .then((r) => go.run(r.instance));
  </script>
</body>
</html>