-
Notifications
You must be signed in to change notification settings - Fork 0
/
net.go
116 lines (100 loc) · 3.11 KB
/
net.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package game
import (
"time"
"github.com/oakmound/lowrez17/game/forceSpace"
"github.com/oakmound/lowrez17/game/layers"
"github.com/oakmound/oak/collision"
"github.com/oakmound/oak/physics"
"github.com/oakmound/oak/render"
)
func NetLeft(label collision.Label) func(*Entity) {
return func(p *Entity) {
PlayAt("NetLight", p.X(), p.Y())
fv := physics.NewForceVector(p.Dir.Copy().Rotate(180), 3)
basePos := p.CenterPos()
rot := p.Dir.Copy().Rotate(-130)
net := render.NewReverting(images["net"].Copy().Modify(render.FlipY))
render.Draw(net, layers.DebugLayer)
go func(rot physics.Vector) {
for a := 0; a < 90; a += 10 {
pos := basePos.Copy()
rot.Rotate(10)
NetRotateAbout(net, pos, basePos, rot.Angle())
time.Sleep(20 * time.Millisecond)
}
net.UnDraw()
}(rot.Copy())
for a := 0; a < 90; a += 10 {
pos := basePos.Copy().Add(rot.Copy().Scale(6))
forceSpace.NewHurtBox(pos.X(), pos.Y(), 5, 5, 75*time.Millisecond, label, fv, false)
rot.Rotate(10)
}
}
}
func NetRight(label collision.Label) func(*Entity) {
return func(p *Entity) {
PlayAt("NetLight", p.X(), p.Y())
fv := physics.NewForceVector(p.Dir.Copy().Rotate(180), 3)
basePos := p.CenterPos()
rot := p.Dir.Copy().Rotate(130)
net := render.NewReverting(images["net"].Copy())
render.Draw(net, layers.DebugLayer)
go func(rot physics.Vector) {
for a := 0; a < 90; a += 10 {
pos := basePos.Copy()
rot.Rotate(-10)
NetRotateAbout(net, pos, basePos, rot.Angle())
time.Sleep(20 * time.Millisecond)
}
net.UnDraw()
}(rot.Copy())
for a := 0; a < 90; a += 10 {
pos := basePos.Copy().Add(rot.Copy().Scale(6))
forceSpace.NewHurtBox(pos.X(), pos.Y(), 5, 5, 75*time.Millisecond, label, fv, false)
rot.Rotate(-10)
}
}
}
func NetRotateAbout(r *render.Reverting, pos, center physics.Vector, angle float64) {
r.RevertAndModify(1, render.Rotate(int(-angle)))
pos2 := pos.Copy().Add(physics.AngleVector(angle).Scale(3))
r.SetPos(pos2.X(), pos2.Y())
w, h := r.GetDims()
if pos2.X() < center.X()-1 {
r.ShiftX(float64(-w))
}
if pos2.Y() < center.Y()-1 {
r.ShiftY(float64(-h))
}
}
func NetTwirl(label collision.Label) func(*Entity) {
return func(p *Entity) {
PlayAt("NetHeavy", p.X(), p.Y())
basePos := p.CenterPos()
rot := p.Dir.Copy().Rotate(-10)
go func(basePos, rot physics.Vector) {
net := render.NewReverting(images["net"].Copy())
render.Draw(net, layers.DebugLayer)
for a := 0; a < 260; a += 10 {
pos := basePos.Copy()
rot.Rotate(-10)
NetRotateAbout(net, pos, basePos, rot.Angle())
time.Sleep(20 * time.Millisecond)
}
net.UnDraw()
}(basePos.Copy(), rot.Copy())
go func(basePos, rot physics.Vector) {
for a := 0; a < 260; a += 10 {
pos := basePos.Copy().Add(rot.Copy().Scale(6))
fv := physics.NewForceVector(rot.Copy().Rotate(90), 3)
forceSpace.NewHurtBox(pos.X(), pos.Y(), 8, 8, 150*time.Millisecond, label, fv)
rot.Rotate(-10)
time.Sleep(5 * time.Millisecond)
}
}(basePos, rot)
// Net's cooldown is too fast for this to be meaningful
// go timing.DoAfter(NetTwirlCooldown, func() {
// PlayAt("NetReady", p.X(), p.Y())
// })
}
}