set scale
This commit is contained in:
15
main.go
15
main.go
@@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"embed"
|
"embed"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
|
||||||
"image"
|
"image"
|
||||||
_ "image/png"
|
_ "image/png"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
@@ -19,8 +18,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
width = 32
|
scale = 2.0
|
||||||
height = 32
|
width = 32 * scale
|
||||||
|
height = 32 * scale
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -64,8 +64,8 @@ func (m *neko) Update() error {
|
|||||||
dx = dx * (-1)
|
dx = dx * (-1)
|
||||||
}
|
}
|
||||||
m.distance = dx + dy
|
m.distance = dx + dy
|
||||||
fmt.Println(m.distance)
|
|
||||||
|
|
||||||
|
// get mouse direction
|
||||||
r := math.Atan2(float64(y), float64(x))
|
r := math.Atan2(float64(y), float64(x))
|
||||||
tr := 0.0
|
tr := 0.0
|
||||||
if r <= 0 {
|
if r <= 0 {
|
||||||
@@ -74,6 +74,9 @@ func (m *neko) Update() error {
|
|||||||
a := (r / math.Pi * 180) + tr
|
a := (r / math.Pi * 180) + tr
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
case m.distance < width:
|
||||||
|
// idle state
|
||||||
|
m.sprite = "wash"
|
||||||
case a < 292.5 && a > 247.5:
|
case a < 292.5 && a > 247.5:
|
||||||
m.y--
|
m.y--
|
||||||
m.sprite = "up"
|
m.sprite = "up"
|
||||||
@@ -118,6 +121,7 @@ func (m *neko) Draw(screen *ebiten.Image) {
|
|||||||
m.count = 0
|
m.count = 0
|
||||||
}
|
}
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
|
op.GeoM.Scale(scale, scale)
|
||||||
screen.DrawImage(img, op)
|
screen.DrawImage(img, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +152,8 @@ func main() {
|
|||||||
ebiten.SetWindowDecorated(false)
|
ebiten.SetWindowDecorated(false)
|
||||||
ebiten.SetWindowFloating(true)
|
ebiten.SetWindowFloating(true)
|
||||||
ebiten.SetWindowSize(width, height)
|
ebiten.SetWindowSize(width, height)
|
||||||
if err := ebiten.RunGame(n); err != nil {
|
err := ebiten.RunGame(n)
|
||||||
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user