Repos / shark / 5feac3e297
commit 5feac3e297f448b6d5a5a02508b2d93b77189520
Author: Nhân <hi@imnhan.com>
Date: Sun Sep 17 16:52:58 2023 +0700
WIP actually walking
TODO: separate game logic and actual window position api calls
diff --git a/main.go b/main.go
index 6b57778..b20622f 100644
--- a/main.go
+++ b/main.go
@@ -120,7 +120,7 @@ func main() {
ebiten.SetWindowPosition(xFlag, yFlag)
ebiten.SetWindowSize(SPRITE_X*sizeFlag, SPRITE_Y*sizeFlag)
ebiten.SetWindowTitle("Shark!")
- ebiten.SetWindowDecorated(false)
+ //ebiten.SetWindowDecorated(false)
ebiten.SetWindowFloating(true)
AppIcon, _ := must.Two(image.Decode(bytes.NewReader(IconFile)))
diff --git a/states.go b/states.go
index ab46a7d..28d102d 100644
--- a/states.go
+++ b/states.go
@@ -1,6 +1,7 @@
package main
import (
+ "fmt"
"time"
"github.com/hajimehoshi/ebiten/v2"
@@ -196,6 +197,16 @@ func (s *StateWalk) Update(sm *StateMachine) {
sm.SetState(&StateRClick{})
return
}
+
+ x, y := ebiten.WindowPosition()
+ newX := x
+ if s.isLeft {
+ newX -= 2
+ } else {
+ newX += 2
+ }
+ fmt.Println(x, "->", newX)
+ ebiten.SetWindowPosition(newX, y)
}
func (s *StateWalk) EndAnimHook(sm *StateMachine) {
if randBool(StopChance) {