Browse Source

FEAT: Added touch support

master
parent
commit
5f9d5c3447
  1. 2
      Makefile
  2. 2
      build/capyclick_iframe.html
  3. 5
      src/main.go

2
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

2
build/capyclick_iframe.html

@ -0,0 +1,2 @@
<!DOCTYPE html>
<iframe src="capyclick.html" width="420" height="740"></iframe>

5
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,

Loading…
Cancel
Save