-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.moonshine
63 lines (51 loc) · 1.31 KB
/
test.moonshine
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
unit Vector[
library [
// Basic constructor Value
fromXY:Vector(x:Number, y:Number){
Runtime.Vector(x,y)
}
// Polar constructor Value
fromMag_angle_unit:Vector(mag:Number, angle:Number, unit:AngleUnit){
Runtime.Vector(
Math.mult(Math.cos(Math.radians(angle, unit) ), mag),
Math.mult(Math.sin(Math.radians(angle, unit) ), mag)
)
}
// Vector math
add:Vector(a:Vector, b:Vector){
Runtime.prepVectors(a,b)
Runtime.Vector(Math.add(a.x, b.x), Math.add(a.y, b.y))
}
// Trigger
trigger whenMagExceedsStage(){
WhatsTheVector.victor(a)
}
// Trigger with Locals
trigger eachFrame (){
locals{
frameCount:Integer <= runtime.frameCount;
elapsed:Float <= runtime.elapsed;
}
Control.eachFrame(expressions)
}
// Context
context forEach (a:String[]){
String.fold(exprs)
}
// Context with locals
context withVector(v:Vector){
locals{
index:Number <= local.iteration;
value:Number <= v[local.iteration];
}
// do something with expressions
Vector.withVector(exprs)
}
// Value
unit:Vector <= Vector.unitVector();
// Step returns a constrained list
asArray:Number[2](vector:Vector){
[vector.x, vector.y]
}
]
]