forked from hackclub/sprig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmice_catcher.js
195 lines (174 loc) · 5.46 KB
/
mice_catcher.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
@title: Mice Catcher
@author: Slippy
@tags: []
@addedOn: 2024-08-06
You, the player must catch the maximum number of mice under one minute
*/
const player = "p"
const floor = "f";
const mouse = "m";
const backgroundTune = tune`
267.85714285714283,
267.85714285714283: E4~267.85714285714283 + F4~267.85714285714283 + G4~267.85714285714283 + A4~267.85714285714283 + D5^267.85714285714283,
267.85714285714283: A4~267.85714285714283 + B4~267.85714285714283,
267.85714285714283: B4~267.85714285714283 + F4^267.85714285714283,
267.85714285714283: B4~267.85714285714283,
267.85714285714283: B4~267.85714285714283 + C5~267.85714285714283,
267.85714285714283: D5~267.85714285714283 + C5~267.85714285714283 + E4^267.85714285714283,
267.85714285714283: C5~267.85714285714283 + B4~267.85714285714283 + A4~267.85714285714283,
267.85714285714283: A4~267.85714285714283 + B4~267.85714285714283,
267.85714285714283: B4~267.85714285714283 + C5~267.85714285714283 + D4^267.85714285714283,
267.85714285714283: C5~267.85714285714283 + A4~267.85714285714283 + G4~267.85714285714283 + F4~267.85714285714283,
267.85714285714283: B4~267.85714285714283 + A4~267.85714285714283 + F4~267.85714285714283,
267.85714285714283: F4~267.85714285714283 + E5^267.85714285714283,
267.85714285714283: F4~267.85714285714283 + G4~267.85714285714283,
267.85714285714283: A4~267.85714285714283 + B4~267.85714285714283 + C5~267.85714285714283,
267.85714285714283: D5~267.85714285714283 + G4^267.85714285714283,
267.85714285714283: D5~267.85714285714283 + E4^267.85714285714283,
267.85714285714283: D5~267.85714285714283 + C5~267.85714285714283 + B4~267.85714285714283 + A4~267.85714285714283 + G4~267.85714285714283,
267.85714285714283: F4~267.85714285714283,
267.85714285714283: F4~267.85714285714283 + G4~267.85714285714283 + G5^267.85714285714283,
267.85714285714283: A4~267.85714285714283 + B4~267.85714285714283 + C5~267.85714285714283 + D5~267.85714285714283,
267.85714285714283: E5~267.85714285714283,
267.85714285714283: E5~267.85714285714283 + D4^267.85714285714283,
267.85714285714283: D5~267.85714285714283 + C5~267.85714285714283 + B4~267.85714285714283 + A4~267.85714285714283 + G4~267.85714285714283,
267.85714285714283: E4~267.85714285714283 + F4~267.85714285714283,
267.85714285714283: F4~267.85714285714283 + G4~267.85714285714283 + A4~267.85714285714283 + E5^267.85714285714283,
267.85714285714283: B4~267.85714285714283 + C5~267.85714285714283 + D5~267.85714285714283,
267.85714285714283: D5~267.85714285714283,
267.85714285714283: D5~267.85714285714283 + C5~267.85714285714283 + E4^267.85714285714283,
267.85714285714283: B4~267.85714285714283 + A4~267.85714285714283 + G4~267.85714285714283 + F4~267.85714285714283,
267.85714285714283: F4~267.85714285714283,
267.85714285714283: F4~267.85714285714283 + G4~267.85714285714283 + B4^267.85714285714283`;
const mouseSound = tune`
112.5,
37.5: A4-37.5 + C5/37.5,
37.5: B4~37.5,
37.5,
37.5: G4-37.5 + C5^37.5 + A4~37.5,
37.5: G4-37.5 + B4^37.5 + A4/37.5,
37.5,
37.5: D5-37.5 + E5-37.5 + F5/37.5,
37.5: E5-37.5 + F5-37.5,
787.5`;
const playBackgroundTune = playTune(backgroundTune, Infinity);
setLegend(
[ player, bitmap`
................
................
................
................
......00.....0..
......010...090.
......0110009900
.00..01111229990
020..01112222990
010..02220220220
0120.02220220220
.02200022222220.
..099920000000..
...092221112220.
...022222222220.
...020200002020.`],
[ floor, bitmap`
111L1111111L1111
111L1111111L1111
111L1111111L1111
LLLLLLLLLLLLLLLL
1111111L1111111L
1111111L1111111L
1111111L1111111L
LLLLLLLLLLLLLLLL
111L1111111L1111
111L1111111L1111
111L1111111L1111
LLLLLLLLLLLLLLLL
1111111L1111111L
1111111L1111111L
1111111L1111111L
LLLLLLLLLLLLLLLL` ],
[ mouse, bitmap`
................
................
................
................
................
................
................
.......000.00...
......08810LL0..
......08810LL0..
......088111110.
..00..008810100.
.08800LLL11111C0
08008LLLLL11880.
.0..0LLLLLLL00..
.....0L00LL0....` ]
)
setSolids([player])
let level = 0
const levels = [
map`
p......
.......
....m..
.......
.......
.......
.......`
]
setMap(levels[level])
setBackground(floor)
setPushables({
[ player ]: []
})
onInput("w", () => {
console.log(getFirst(player).y);
getFirst(player).y -= 1
})
onInput("s", () => {
console.log(getFirst(player).y);
getFirst(player).y += 1
})
onInput("d", () => {
console.log(getFirst(player).x);
getFirst(player).x += 1
})
onInput("a", () => {
console.log(getFirst(player).x);
getFirst(player).x -= 1
})
let score = 0;
addText(`Score: ${score}`, {x: 10, y: 0, color:color`2`});
const mouseSprite = getFirst(mouse);
function randomizeCoordinatesMouse() {
mouseSprite.x = Math.floor(Math.random() * 7);
mouseSprite.y = Math.floor(Math.random() * 7);
addText(`Score: ${score}`, {x: 10, y: 0, color:color`2`});
}
let seconds = 60;
addText(`Time: ${seconds}`, {x: 10, y: 1, color:color`2`});
function countdown() {
const timer = setInterval(() => {
seconds--;
addText(`Time: ${seconds}`, {x: 10, y: 1, color:color`2`});
if (seconds == 0) {
clearInterval(timer);
clearText();
addText(`Time's up!`, {x: 6, y: 7, color:color`2`});
addText(`You caught`, {x: 6, y: 8, color:color`2`});
addText(`${score} mice`, {x: 7, y: 9, color:color`2`});
playBackgroundTune.end();
}
}, 1000)
}
randomizeCoordinatesMouse();
countdown();
afterInput(() => {
if(tilesWith(mouse, player).length >= 1) {
score++;
playTune(mouseSound);
randomizeCoordinatesMouse();
};
})