-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparticle.go
37 lines (32 loc) · 775 Bytes
/
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
package main
import (
"github.com/faiface/pixel"
"github.com/faiface/pixel/imdraw"
"github.com/faiface/pixel/pixelgl"
)
type Particle struct {
window *pixelgl.Window
xNoise *NoiseLoop
yNoise *NoiseLoop
rNoise *NoiseLoop
imd *imdraw.IMDraw
}
func (p *Particle) Draw(a float64) {
x := p.xNoise.Value(a, false)
y := p.yNoise.Value(a, false)
r := p.rNoise.Value(a, false)
p.imd.Clear()
p.imd.Color = pixel.RGB(0, 0, 0)
p.imd.Push(pixel.V(x, y))
p.imd.Circle(r, r/2)
p.imd.Draw(p.window)
}
func NewParticle(win *pixelgl.Window) *Particle {
var p Particle
p.window = win
p.xNoise = NewNoiseLoop(0.1, 150, win.Bounds().W()*2)
p.yNoise = NewNoiseLoop(0.2, 150, win.Bounds().H()*2)
p.rNoise = NewNoiseLoop(4, 10, 25)
p.imd = imdraw.New(nil)
return &p
}