-
-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathfall.js
52 lines (44 loc) · 929 Bytes
/
fall.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
// @ts-check
// Build levels with addLevel()
// Start game
kaplay();
// Load assets
loadSprite("coin", "/sprites/coin.png");
loadSprite("grass", "/sprites/grass.png");
setGravity(2400);
addLevel([
// Design the level layout with symbols
" ",
" ",
" ",
" ",
"=======",
], {
// The size of each grid
tileWidth: 64,
tileHeight: 64,
// The position of the top left block
pos: vec2(100),
// Define what each symbol means (in components)
tiles: {
"=": () => [
sprite("grass"),
area(),
body({ isStatic: true }),
],
},
});
loop(0.2, () => {
const coin = add([
pos(rand(100, 400), 0),
sprite("coin"),
area(),
body(),
"coin",
]);
wait(3, () => coin.destroy());
});
debug.paused = true;
onKeyPressRepeat("space", () => {
debug.stepFrame();
});