-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdance.js
41 lines (32 loc) · 1.05 KB
/
dance.js
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
function getRandomInt(min, max) {
return Math.floor(Math.random()*(max - min + 1)) + min;
}
misty.RegisterTimerEvent("head_move", 6240, false);
misty.RegisterTimerEvent("arms_move", 6240, false);
misty.RegisterTimerEvent("rainbowLED", 1, false);
misty.PlayAudio("Daft-Punk-Harder-Better-Faster-S.mp3", 10);
function _head_move(repeat = true) {
misty.MoveHeadDegrees(
getRandomInt(-40,20),
getRandomInt(-30,30),
getRandomInt(-40,40),
100);
if (repeat) misty.RegisterTimerEvent(
"head_move", 480, false);
}
function _arms_move(repeat = true) {
misty.Debug("arms");
var move_amount = Math.round(Math.random() * 180)
misty.MoveArmDegrees("right", move_amount - 90, 80);
misty.MoveArmDegrees("left", move_amount - 90, 80);
if(repeat) misty.RegisterTimerEvent("arms_move", 480, false);
}
function _rainbowLED(){
i=0
while(true){
i++;
misty.ChangeLED(i%255, (i+85)%255, (i+170)%255);
misty.Pause(1);
}
misty.RegisterTimerEvent("rainbowLED", 1, false);
}