forked from hackclub/sprig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcatch_orpheus.js
129 lines (114 loc) · 2.29 KB
/
catch_orpheus.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
/*
@title: catch_orpheus
@author: sampoder
@tags: ["endless"]
@addedOn: 2022-10-08
Instructions
in this game, use WASD to try and
catch Orpheus as she moves in all sorts
of directions! good luck!
*/
const player = "p";
const orpheus = "o";
const background = "b";
setLegend(
[ player, bitmap`
3333333333333333
3333333333333333
3333333333333333
3333323333333333
3333323333333333
3333323333333333
3333323333333333
3333323333333333
3333323222233333
3333322333233333
3333323333233333
3333323333233333
3333333333333333
3333333333333333
3333333333333333
3333333333333333`],
[ orpheus, bitmap`
................
....0000000.....
....022222000...
...0222202220...
...0222022220...
...0222222220...
....022222220...
....000002220...
........02220...
........02220...
........02220...
........02220...
........02220...
........00000...
................
................`],
[ background, bitmap`
DDDDDDDDDDDDDDDD
DDDDDDDDD4DDDDDD
DCD4DDDDDDDD4DDD
DDDDDDDDDDDDDDDD
DDDDDDD4DDDDDDDD
DD4DDDDDDDDD44DD
DDDDDDDDDDDDDDDD
DDDDDDDDDCDDDDDD
DDDCDD4DDDDDDD4D
DDDDDDDDDDDDDDDD
4DDDD4DDDDDDDDDD
DDDDDDDDD4DDDDDD
DDCDDDDDDDDDDD4D
DDDDD4DDDDDDDDDD
DDDDDDDDDDD4DDDD
DDDDDCDDDDDDDDDD`]
);
setSolids([]);
let level = 0;
const levels = [
map`
p......
..o....
.......
.......
.......
.......`,
];
setBackground(background)
setMap(levels[level]);
setPushables({
[ player ]: [],
});
onInput("s", () => {
getFirst(player).y += 1
// console.log(Math.floor(Math.random() * 10) - 5)
getFirst(orpheus).y += Math.floor(Math.random() * 5) - 2
});
onInput("w", () => {
getFirst(player).y -= 1
// console.log(Math.floor(Math.random() * 10) - 5)
getFirst(orpheus).y += Math.floor(Math.random() * 5) - 2
});
onInput("a", () => {
getFirst(player).x -= 1
// console.log(Math.floor(Math.random() * 10) - 5)
getFirst(orpheus).x += Math.floor(Math.random() * 5) - 2
});
onInput("d", () => {
getFirst(player).x += 1
// console.log(Math.floor(Math.random() * 10) - 5)
getFirst(orpheus).x += Math.floor(Math.random() * 5) - 2
});
afterInput(() => {
if(getFirst(player).x == getFirst(orpheus).x
&& getFirst(player).y == getFirst(orpheus).y){
addText("you win!", {
x: 10,
y: 4,
color: color`3`
})
setTimeout(() => setMap(levels[0]), 2000)
setTimeout(() => clearText(), 2000)
}
});