-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnakeSnack3
187 lines (161 loc) · 2.77 KB
/
SnakeSnack3
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
/*
@title: SnakeSnack
@author: Meghna Pichhika
@tags: []
@addedOn: 2024-00-00
*/
const player = "p"
const body = "b"
const background = "k"
const wall ="w"
const snack ="c"
const myTune = tune`
1000,
500: C5~500,
14500`;
setLegend(
[ player, bitmap`
0000000000000000
000033H973330000
0003333333333000
0033333333333300
0333333333333330
0333322332233330
0333320330233330
0333320330233330
0338833333388330
0333333333333330
0333303333033330
0333300000033330
0033333333333300
0003333333333000
0000333333330000
0000000000000000`],
[body,bitmap`
0000000000000000
0000000000000000
0000333333330000
0003333333333000
0033333333333300
0333333333333330
0333333333333330
0333333333333330
0333333333333330
0333333333333330
0333333333333330
0333333333333330
0033333333333300
0003333333333000
0000333333330000
0000000000000000`],
[background,bitmap`
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000`],
[wall,bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
[snack, bitmap`
0000000000000000
0000000L40000000
0000000LD0000000
0000000L00000000
0000999999990000
0009999999999000
0099929999999900
0099299999999900
0099999999999900
0099999999999900
0099999999999900
0099999999999900
0099999999999900
0009999999999000
0000999999990000
0000000000000000`
]
)
setBackground([background]);
let level =0;
const levels = [
map`
wwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwww
wkkkkkkkkkkkkkkkkkkw
wkkkkkkkkkkkkkkkkkkw
wkkkkkkkkkkkkkkkkkkw
wkkkkkkkkkkkkkkkkkkw
wkkkkkkpkkkkkkkkkkkw
wkkkkkkkkkkkkkkkkkkw
wkkkkkkkkkkkkkkkkkkw
wkkkkkkkkkkkkkkkkkkw
wkkkkkkkkkkkkkkkkkkw
wkkkkkkkkkkkkkkkkkkw
wkkkkkkkkkkkkckkkkkw
wkkkkkkkkkkkkkkkkkkw
wkkkkkkkkkkkkkkkkkkw
wkkkkkkkkkkkkkkkkkkw
wkkkkkkkkkkkkkkkkkkw
wwwwwwwwwwwwwwwwwwww`,
];
let score =0;
addText("Score:" + score,
{x:6,
y:1,
color: color`2` })
setSolids(["w"]);
// inputs for player movement control
onInput("s", () => {
getFirst(player).y += 1;
playTune(myTune);// positive y is downwards
});
onInput("d", () => {
getFirst(player).x += 1;//right
playTune(myTune);
});
onInput("w",() => {
getFirst(player).y -= 1;//up
playTune(myTune);
});
onInput("a",() => {
getFirst(player).x -= 1;//left
playTune(myTune);
});
var mode = "easy";
var reset = "l";
setMap(levels[level])
setPushables({
[ player ]: []
})
onInput("s", () => {
getFirst(player).y += 1
})
afterInput(() => {
})