Skip to content

Commit b3957dc

Browse files
Add Bullet Heaven (#2041)
* Add files via upload * Add files via upload * add cooldown to shooting * fixes and improvements * Update bullet_heaven.js * Update bullet_heaven.js * fix bug by removing the ability to move up and down because its basically useless in this game * apparently i didn't have quotation marks in the sprig editor version * last change i didn't sync back to sprig * Fixing metadata --------- Co-authored-by: graham <[email protected]>
1 parent a4f16b4 commit b3957dc

File tree

2 files changed

+299
-0
lines changed

2 files changed

+299
-0
lines changed

games/bullet_heaven.js

Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
/*
2+
@title: Bullet Heaven
3+
@author: OtterDev
4+
@tags: ["shooter"]
5+
@addedOn: 2024-07-30
6+
*/
7+
8+
const player = "p";
9+
const jerk = "j";
10+
const bullet = "b";
11+
const wall = "w"
12+
const playerWall = "i"
13+
const jerkBullet = "u";
14+
let jerkHealth = 40;
15+
let jerkMovingLeft = false;
16+
let stillAlive = true;
17+
const bulletNoise = tune`
18+
500: C4-500,
19+
15500`
20+
const jerkSpeed = 400;
21+
const winNoise = tune`
22+
500: C4/500,
23+
500: D4/500,
24+
500: E4/500,
25+
14500`
26+
const deadNoise = tune`
27+
500: E4/500,
28+
500: D4/500,
29+
500: C4/500,
30+
14500`
31+
let jerkCanShoot = true;
32+
let canShoot = true;
33+
34+
function delay(time) {
35+
return new Promise(resolve => setTimeout(resolve, time));
36+
}
37+
setLegend(
38+
[player, bitmap`
39+
0000000000000000
40+
0000000000000000
41+
0022200000022200
42+
0022200000022200
43+
0022200000022200
44+
0000000000000000
45+
0000000000000000
46+
0000000000000000
47+
0000000000000000
48+
0000000000000000
49+
0000000000000000
50+
0000000000000000
51+
0000002222000000
52+
0000000000000000
53+
0000000000000000
54+
0000000000000000`],
55+
[jerk, bitmap`
56+
3333333333333333
57+
3033333333333303
58+
3303333333333033
59+
3330333333330333
60+
3333333333333333
61+
3333303333033333
62+
3333303333033333
63+
3333303333033333
64+
3333333333333333
65+
3333333333333333
66+
3333333333333333
67+
3333333333333333
68+
3333330000333333
69+
3333303333033333
70+
3333303333033333
71+
3333303333033333`],
72+
[bullet, bitmap`
73+
....66666666....
74+
....66666666....
75+
...6666666666...
76+
...6666666666...
77+
..666666666666..
78+
..666666666666..
79+
..666666666666..
80+
..666666666666..
81+
..666666666666..
82+
..666666666666..
83+
..666666666666..
84+
..666666666666..
85+
..666666666666..
86+
..666666666666..
87+
..FFFFFFFFFFFF..
88+
..FFFFFFFFFFFF..`],
89+
[jerkBullet, bitmap`
90+
..CCCCCCCCCCCC..
91+
..CCCCCCCCCCCC..
92+
..333333333333..
93+
..333333333333..
94+
..333333333333..
95+
..333333333333..
96+
..333333333333..
97+
..333333333333..
98+
..333333333333..
99+
..333333333333..
100+
..333333333333..
101+
..333333333333..
102+
...3333333333...
103+
...3333333333...
104+
....33333333....
105+
....33333333....`],
106+
[wall, bitmap`
107+
3333333333333333
108+
3333333333333333
109+
3333333333333333
110+
3333333333333333
111+
3333333333333333
112+
3333333333333333
113+
3333333333333333
114+
3333333333333333
115+
3333333333333333
116+
3333333333333333
117+
3333333333333333
118+
3333333333333333
119+
3333333333333333
120+
3333333333333333
121+
3333333333333333
122+
3333333333333333`],
123+
[playerWall, bitmap`
124+
................
125+
................
126+
................
127+
................
128+
................
129+
................
130+
................
131+
................
132+
................
133+
................
134+
................
135+
................
136+
................
137+
................
138+
................
139+
................`],
140+
)
141+
142+
setSolids([])
143+
144+
const level = map`
145+
wwwwwwww
146+
........
147+
j.......
148+
........
149+
........
150+
...p....
151+
iiiiiiii`
152+
153+
154+
setMap(level)
155+
156+
setPushables({
157+
[player]: []
158+
})
159+
getFirst(player).y += 1;
160+
/* i think it'd make more sense to just scrap moving up and down as its basically useless
161+
and opens up the opportunity for bugs
162+
onInput("s", () => {
163+
if (stillAlive) {
164+
getFirst(player).y += 1;
165+
}
166+
});
167+
*/
168+
onInput("d", () => {
169+
if (stillAlive) {
170+
getFirst(player).x += 1;
171+
}
172+
});
173+
/*
174+
onInput("w", () => {
175+
if (stillAlive) {
176+
getFirst(player).y -= 1;
177+
}
178+
});
179+
*/
180+
onInput("a", () => {
181+
if (stillAlive) {
182+
getFirst(player).x -= 1;
183+
}
184+
});
185+
onInput("l", () => {
186+
if (stillAlive && canShoot) {
187+
addSprite(getFirst(player).x, getFirst(player).y, bullet)
188+
canShoot = false
189+
}
190+
});
191+
onInput("i", () => {
192+
if (stillAlive && canShoot) {
193+
addSprite(getFirst(player).x, getFirst(player).y, bullet)
194+
canShoot = false
195+
}
196+
});
197+
onInput("j", () => {
198+
if (stillAlive && canShoot) {
199+
addSprite(getFirst(player).x, getFirst(player).y, bullet)
200+
canShoot = false
201+
}
202+
});
203+
onInput("k", () => {
204+
if (stillAlive && canShoot) {
205+
addSprite(getFirst(player).x, getFirst(player).y, bullet)
206+
canShoot = false
207+
}
208+
});
209+
210+
function moveBullets() {
211+
let bullets = getAll(bullet);
212+
let jerkBullets = getAll(jerkBullet);
213+
for (let i = 0; i < bullets.length; i++) {
214+
bullets[i].y -= 1;
215+
}
216+
for (let i = 0; i < jerkBullets.length; i++) {
217+
jerkBullets[i].y += 1;
218+
}
219+
}
220+
let timer = setInterval(() => {
221+
moveBullets()
222+
const bullets = getAll(bullet);
223+
const jerkBullets = getAll(jerkBullet);
224+
const walls = getAll(wall);
225+
const playerWalls = getAll(playerWall);
226+
if (getFirst(jerk).x === getFirst(player).x && jerkCanShoot) {
227+
addSprite(getFirst(jerk).x, getFirst(jerk).y, jerkBullet)
228+
jerkCanShoot = false
229+
}
230+
jerkBullets.forEach(bullet => {
231+
if (getFirst(player).x === bullet.x && getFirst(player).y === bullet.y) {
232+
bullet.remove()
233+
stillAlive = false;
234+
playTune(deadNoise)
235+
addText(`you died!`, {
236+
x: 5,
237+
y: 5,
238+
color: color`9`
239+
})
240+
clearInterval(timer)
241+
}
242+
playerWalls.forEach(wall => {
243+
if (bullet.x === wall.x && bullet.y === wall.y) {
244+
bullet.remove();
245+
}
246+
});
247+
});
248+
bullets.forEach(bullet => {
249+
walls.forEach(wall => {
250+
if (bullet.x === wall.x && bullet.y === wall.y) {
251+
bullet.remove();
252+
}
253+
});
254+
if (bullet.x === getFirst(jerk).x && bullet.y === getFirst(jerk).y && stillAlive) {
255+
if (jerkHealth <= 1) {
256+
// set stillalive to false so it has the same effect as if you died
257+
stillAlive = false
258+
clearInterval(jerkTimer)
259+
getFirst(jerk).remove();
260+
playTune(winNoise);
261+
addText(`you won!`, {
262+
x: 5,
263+
y: 5,
264+
color: color`F`
265+
})
266+
clearInterval(timer)
267+
return;
268+
}
269+
jerkHealth -= 1;
270+
playTune(bulletNoise)
271+
bullet.remove()
272+
}
273+
274+
});
275+
}, 100);
276+
let jerkTimer = setInterval(() => {
277+
if (!stillAlive) {
278+
return;
279+
}
280+
if (getFirst(jerk).x === 0) {
281+
jerkMovingLeft = false;
282+
}
283+
if (getFirst(jerk).x < 7) {
284+
if (jerkMovingLeft) {
285+
getFirst(jerk).x -= 1
286+
} else {
287+
getFirst(jerk).x += 1
288+
}
289+
} else {
290+
jerkMovingLeft = true
291+
getFirst(jerk).x -= 1
292+
}
293+
}, jerkSpeed);
294+
let bulletTimer = setInterval(() => {
295+
jerkCanShoot = true
296+
}, 2000)
297+
let playerTimer = setInterval(() => {
298+
canShoot = true
299+
}, 200)

games/img/bullet_heaven.png

1.32 KB
Loading

0 commit comments

Comments
 (0)