No scrolling
This commit is contained in:
10
main.go
10
main.go
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user