41 lines
510 B
Go
41 lines
510 B
Go
|
|
package main
|
||
|
|
|
||
|
|
type Explosion struct {
|
||
|
|
Radius float64
|
||
|
|
Origin Coordinates
|
||
|
|
cycle int
|
||
|
|
Active bool
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewExplosion() *Explosion {
|
||
|
|
return &Explosion{
|
||
|
|
cycle: 1,
|
||
|
|
Active: false,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (e *Explosion) Draw() {
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
func (e *Explosion) Update() {
|
||
|
|
|
||
|
|
if e.Active {
|
||
|
|
e.Radius = float64(e.cycle) / 0.15
|
||
|
|
e.cycle++
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
func (e *Explosion) SetOrigin(origin Coordinates) {
|
||
|
|
e.Origin = origin
|
||
|
|
}
|
||
|
|
|
||
|
|
func (e *Explosion) ToggleActivate() {
|
||
|
|
e.Active = !e.Active
|
||
|
|
}
|
||
|
|
|
||
|
|
func (e *Explosion) Reset() {
|
||
|
|
e.cycle = 1
|
||
|
|
}
|