/
particle.go
55 lines (45 loc) · 1.09 KB
/
particle.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Package particle provides options for generating renderable
// particle sources.
package particle
import (
"image/draw"
"github.com/oakmound/oak/physics"
"github.com/oakmound/oak/render"
)
// A Particle is a renderable that is spawned by a generator, usually very fast,
// usually very small, for visual effects
type Particle interface {
render.Renderable
GetBaseParticle() *baseParticle
GetPos() physics.Vector
DrawOffsetGen(gen Generator, buff draw.Image, xOff, yOff float64)
Cycle(gen Generator)
setPID(int)
}
type baseParticle struct {
render.LayeredPoint
Src *Source
Vel physics.Vector
Life float64
totalLife float64
pID int
}
func (bp *baseParticle) GetLayer() int {
if bp == nil {
return render.Undraw
}
return bp.LayeredPoint.GetLayer()
}
func (bp *baseParticle) GetBaseParticle() *baseParticle {
return bp
}
func (bp *baseParticle) GetPos() physics.Vector {
return bp.Vector
}
func (bp *baseParticle) GetDims() (int, int) {
return 0, 0
}
func (bp *baseParticle) Cycle(gen Generator) {}
func (bp *baseParticle) setPID(pid int) {
bp.pID = pid
}