No scrolling
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"gitlab.com/kbr4/9heroja/resources"
|
||||
"image"
|
||||
"log"
|
||||
"math"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -28,6 +29,8 @@ type Zombie struct {
|
||||
OffsetX float64
|
||||
OffsetY float64
|
||||
IsDead bool
|
||||
TargetX float64
|
||||
TargetY float64
|
||||
}
|
||||
|
||||
type spritePosition struct {
|
||||
@@ -94,6 +97,8 @@ func NewZombie() *Zombie {
|
||||
if zombie.step > 3 {
|
||||
zombie.step = 0
|
||||
}
|
||||
|
||||
zombie.Move()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,6 +111,7 @@ func (z *Zombie) Walk() {
|
||||
if !z.IsWalking {
|
||||
walkTicker.Reset(WalkSpeedMs * time.Millisecond)
|
||||
z.IsWalking = true
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -154,3 +160,11 @@ func (z *Zombie) HandleCollisionEvent(other collision.Collidable) {
|
||||
z.IsDead = true
|
||||
}
|
||||
}
|
||||
|
||||
func (z *Zombie) Move() {
|
||||
fmt.Printf("Zombie target: %f, %f\n", z.TargetX, z.TargetY)
|
||||
directionX := (z.TargetX - z.X) / math.Abs(z.TargetX+z.X)
|
||||
directionY := (z.TargetY - z.Y) / math.Abs(z.TargetY+z.Y)
|
||||
z.X += directionX
|
||||
z.Y += directionY
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user