-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsys_effect.go
53 lines (44 loc) · 900 Bytes
/
sys_effect.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
package kar
import (
"kar/res"
"math"
"github.com/hajimehoshi/ebiten/v2"
)
// block breaking effect system
type Effects struct {
g float64
}
func (e *Effects) Init() {
e.g = 0.2
}
func (e *Effects) Update() {
q := filterEffect.Query()
for q.Next() {
_, p, v, _ := q.Get()
v.Y += e.g
p.Y += v.Y
if p.Y > cameraRes.Y+cameraRes.Height {
toRemove = append(toRemove, q.Entity())
}
}
}
func (e *Effects) Draw() {
q := filterEffect.Query()
for q.Next() {
id, p, v, r := q.Get()
colorMDIO.GeoM = ebiten.GeoM{}
colorMDIO.GeoM.Translate(-4, -4)
colorMDIO.GeoM.Rotate(r.Angle)
colorMDIO.GeoM.Translate(4, 4)
colorMDIO.GeoM.Translate(p.X, p.Y)
colorM.Scale(1.3, 1.3, 1.3, 1)
cameraRes.DrawWithColorM(res.Icon8[id.ID], colorM, colorMDIO, Screen)
colorM.Reset()
if math.Signbit(r.Angle) {
r.Angle -= 0.2
} else {
r.Angle += 0.2
}
p.X += v.X * 2
}
}