-
Notifications
You must be signed in to change notification settings - Fork 0
/
globalState.js
62 lines (55 loc) · 1.88 KB
/
globalState.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// @flow
// screw your paradigms, I just want a bit of mostly-static global data.
export default class GlobalState {
static connectedBles = {};
static beanConsts = { // UUIDs of the serial/scratch service/characteristic on a LightBlue Bean device
serial_service_UUID: 'a495ff10-c5b1-4b44-b512-1370f02d74de',
scratch_service_UUID: 'a495ff20-c5b1-4b44-b512-1370f02d74de',
serial_UUID: 'a495ff11-c5b1-4b44-b512-1370f02d74de',
scratch_UUID: 'a495ff25-c5b1-4b44-b512-1370f02d74de'
};
static starterGames = {
screentap: 'tap -> feed()',
turtletap: `
st()
sizePicker = new DifficultyPicker 20, 1
onRoundStart ->
setSize sizePicker.pick()
turtle.tap ->
feed()
moveto random position
`,
tapblue:`
speed Infinity
boxSize = max(totalWidth, totalHeight)/2
boxCenters = [
[-boxSize/2, -boxSize/2]
[-boxSize/2, boxSize/2]
[boxSize/2, boxSize/2]
[boxSize/2, -boxSize/2]
]
boxColors = [black, yellow, white, blue]
# set up box size difficulty:
# a box 3 times the normal size will take up the whole screen, so we will make that the easiest size.
# the hardest size is the "regular" size.
sizePicker = new DifficultyPicker boxSize*3, boxSize
onRoundStart ->
cg()
# pick a size for the blue box, based on difficulty:
blueBoxSize = sizePicker.pick()
shuffle boxCenters
for i in [0..3]
moveto boxCenters[i]
if boxColors[i] == blue
# if this is a blue box, use our special size
box boxColors[i], blueBoxSize
else
# if it's not a blue box, use the regular box size
box boxColors[i], boxSize
# on tap, see if the tap was on blue. if yes, feed the dog!
tap ->
if lasttap.touches blue
feed()
`
}
};