No scrolling

This commit is contained in:
2024-01-08 06:19:39 +01:00
parent 156e3ed43c
commit a838fcec48
4 changed files with 39 additions and 24 deletions

10
main.go
View File

@@ -72,7 +72,7 @@ func (g *Game) Update() error {
if len(g.keys) <= 0 {
g.hero.Stop()
} else {
g.terrain.Move()
g.hero.Move()
g.hero.Walk()
}
@@ -81,6 +81,10 @@ func (g *Game) Update() error {
b.Move()
}
}
for _, z := range g.zombies {
z.TargetX = g.hero.X
z.TargetY = g.hero.Y
}
g.world.NotifyAboutCollisions()
return nil
@@ -89,8 +93,6 @@ func (g *Game) Update() error {
func (g *Game) Draw(screen *ebiten.Image) {
g.terrain.DrawTerrain(screen)
for _, z := range g.zombies {
z.OffsetX = g.terrain.PositionX
z.OffsetY = g.terrain.PositionY
z.DrawZombie(screen)
}
@@ -126,6 +128,8 @@ func init() {
GameInstance.world.AddEntity(GameInstance.hero)
// put zombies in random places on the screen but not too close to the hero or each other
for _, z := range GameInstance.zombies {
z.TargetX = GameInstance.hero.X
z.TargetY = GameInstance.hero.Y
z.X = float64(configuration.Random(50, screenWidth-50))
z.Y = float64(configuration.Random(50, screenHeight-50))
for z.X > float64(screenWidth/2-64) && z.X < float64(screenWidth/2+64) && z.Y > float64(screenHeight/2-64) && z.Y < float64(screenHeight/2+64) {