forked from hackclub/sprig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ch_2_walk.js
46 lines (39 loc) · 650 Bytes
/
ch_2_walk.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
/*
@title: Ch 2 Walk
@author: hackclub
This bean can walk left and down.
Can you add controls to walk right and up also?
Hint: we use w, a, s, d as inputs, check the help tab
*/
const bean = 'a';
setLegend(
[bean, bitmap`
................
......000.......
.....0.220......
.....002020.....
..0..022..0.....
...0..0...0.....
...0000...20....
....2.0...20....
.....0....200...
....0...220.0...
....0...220.0...
....02.220...2..
.....0000.......
....0....0......
....0....0......
...00...00......`]
);
setMap(map`
.....
.....
..a..
.....
.....`);
onInput("a", () => {
getFirst(bean).x -= 1
});
onInput("s", () => {
getFirst(bean).y += 1
});