Cloud layer.
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"image/color"
|
||||
"math"
|
||||
"math/rand/v2"
|
||||
"mover/assets"
|
||||
"mover/elements"
|
||||
"mover/fonts"
|
||||
@@ -50,6 +51,7 @@ func NewCanvas(a gamedata.Area) *Canvas {
|
||||
goblinspawned: false,
|
||||
score: 0,
|
||||
runtime: 0.,
|
||||
counter: 0,
|
||||
}
|
||||
c.eventmap = make(map[gamedata.GameEvent]func())
|
||||
return c
|
||||
@@ -70,9 +72,9 @@ func (c *Canvas) Update() error {
|
||||
c.UpdateCharge()
|
||||
c.UpdateEnemies()
|
||||
c.CleanupTargets()
|
||||
|
||||
c.counter++
|
||||
}
|
||||
c.counter++
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -105,7 +107,7 @@ func (c *Canvas) Draw(drawimg *ebiten.Image) {
|
||||
if e.Health() > 0 {
|
||||
x0 := e.GetPosition().X - float64(e.GetSprite().Bounds().Dx())
|
||||
y0 := e.GetPosition().Y - 2/3.*float64(e.GetSprite().Bounds().Dy())
|
||||
vector.DrawFilledRect(c.Sprite, float32(x0), float32(y0), 204, 12, color.Black, true)
|
||||
vector.DrawFilledRect(c.Sprite, float32(x0), float32(y0), float32(e.MaxHealth())*2+4, 12, color.Black, true)
|
||||
vector.DrawFilledRect(c.Sprite, float32(x0+2), float32(y0+2), float32(e.Health())*2, 8, color.RGBA{R: 0xff, G: 0x00, B: 0x00, A: 0xff}, true)
|
||||
}
|
||||
}
|
||||
@@ -351,7 +353,8 @@ func (c *Canvas) UpdateEnemies() {
|
||||
e.Update()
|
||||
}
|
||||
if !c.gameover {
|
||||
/*
|
||||
|
||||
if !c.goblinspawned {
|
||||
//spawn new enemies
|
||||
f := 40000 / (c.counter + 1)
|
||||
|
||||
@@ -376,13 +379,15 @@ func (c *Canvas) UpdateEnemies() {
|
||||
newenemy.SetTarget(c.hero.Pos)
|
||||
|
||||
c.enemies = append(c.enemies, newenemy)
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
if !c.goblinspawned {
|
||||
if !c.goblinspawned && c.counter > 1200 {
|
||||
newfg := elements.NewFlyGoblin()
|
||||
c.enemies = append(c.enemies, newfg)
|
||||
c.goblinspawned = true
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user