From 5f9d5c3447aa794eb6f9cf4805e2242fd5b7e091 Mon Sep 17 00:00:00 2001 From: Unbewohnte Date: Sat, 1 Jun 2024 19:19:14 +0300 Subject: [PATCH] FEAT: Added touch support --- Makefile | 2 ++ build/capyclick_iframe.html | 2 ++ src/main.go | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 build/capyclick_iframe.html diff --git a/Makefile b/Makefile index 3bb3ca1..e669cac 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ game:=capyclick desktopBin:=bin/desktop webBin:=bin/web wasmHtml:=build/capyclick.html +wasmHtmlIFrame:=build/capyclick_iframe.html wasmExec:=$(shell go env GOROOT)/misc/wasm/wasm_exec.js current: clean environment @@ -10,6 +11,7 @@ current: clean environment web: environment cd src && env GOOS=js GOARCH=wasm go build -o $(game).wasm . && mv $(game).wasm ../$(webBin) cp $(wasmHtml) $(webBin) + cp $(wasmHtmlIFrame) $(webBin) cp $(wasmExec) $(webBin) desktop: clean environment diff --git a/build/capyclick_iframe.html b/build/capyclick_iframe.html new file mode 100644 index 0000000..11ef1c4 --- /dev/null +++ b/build/capyclick_iframe.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/main.go b/src/main.go index 87b6b2e..7c60aa1 100644 --- a/src/main.go +++ b/src/main.go @@ -160,7 +160,8 @@ func (g *Game) Update() error { } } - if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonLeft) { + if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonLeft) || + len(inpututil.AppendJustPressedTouchIDs(nil)) != 0 { // Click! g.Save.TimesClicked++ g.Save.Points++ @@ -279,7 +280,7 @@ func (g *Game) Draw(screen *ebiten.Image) { ) // Volume - msg = fmt.Sprintf("Volume: %d%%", int(g.Config.Volume*100.0)) + msg = fmt.Sprintf("Volume: %d%% (← or →)", int(g.Config.Volume*100.0)) text.Draw( screen, msg,