Skip to content

Commit 1cc7a7e

Browse files
22yeets22grymmy
andauthored
[Sprig App] Skibidi Slicers (#2786)
* Sprig App - Skibidi Slicers * Fixing metadata --------- Co-authored-by: graham <[email protected]>
1 parent a3efc7f commit 1cc7a7e

File tree

1 file changed

+352
-0
lines changed

1 file changed

+352
-0
lines changed

games/Skibidi-Slicers.js

+352
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,352 @@
1+
/*
2+
@title: Skibidi Slicers
3+
@author: 22yeets22
4+
@tags: []
5+
@addedOn: 2025-01-17
6+
*/
7+
const player = "p";
8+
const enemy = "e";
9+
const swordUp = "u";
10+
const swordLeft = "l";
11+
const swordRight = "r";
12+
const swordDown = "d";
13+
const background = "b";
14+
15+
// Add cooldown configuration
16+
let lastSwordThrow = 0;
17+
18+
setLegend(
19+
[player, bitmap`
20+
........000.....
21+
.7.....00..0....
22+
.77....0...00...
23+
..7....0....0...
24+
..755...00000...
25+
..500...0.......
26+
.5.C.000........
27+
....C..0000.....
28+
......0...0.....
29+
......0.........
30+
....000.........
31+
...00..0........
32+
..00...0........
33+
.00.....0.......
34+
........0.......
35+
........0.......`],
36+
[enemy, bitmap`
37+
.....2CCC.2.....
38+
.....CCCCC2.....
39+
....2C0C0C2.....
40+
....2CCCC02.....
41+
....2.C00C2.....
42+
....22CCC22.....
43+
..2277CC7722....
44+
..2277CC7772....
45+
..2227CC7722....
46+
..2222222222....
47+
..2222222222....
48+
..2222222222....
49+
..222222222.....
50+
...2222222......
51+
...222222.......
52+
....22222.......`],
53+
[swordUp, bitmap`
54+
................
55+
.......7........
56+
.......7........
57+
.......7........
58+
.......77.......
59+
.......77.......
60+
.......77.......
61+
.......77.......
62+
.......77.......
63+
.......77.......
64+
......5757......
65+
.....555555.....
66+
.......CC.......
67+
.......CC.......
68+
.......CC.......
69+
.......C........`],
70+
[swordLeft, bitmap`
71+
................
72+
................
73+
................
74+
................
75+
................
76+
...........5....
77+
..........75....
78+
....77777755CCC.
79+
.77777777775CCCC
80+
..........55....
81+
...........5....
82+
................
83+
................
84+
................
85+
................
86+
................`],
87+
[swordRight, bitmap`
88+
................
89+
................
90+
................
91+
................
92+
................
93+
....5...........
94+
....55..........
95+
CCCC57777777777.
96+
.CCC55777777....
97+
....57..........
98+
....5...........
99+
................
100+
................
101+
................
102+
................
103+
................`],
104+
[swordDown, bitmap`
105+
........C.......
106+
.......CC.......
107+
.......CC.......
108+
.......CC.......
109+
.....555555.....
110+
......7575......
111+
.......77.......
112+
.......77.......
113+
.......77.......
114+
.......77.......
115+
.......77.......
116+
.......77.......
117+
........7.......
118+
........7.......
119+
........7.......
120+
................`],
121+
[background, bitmap`
122+
4444444444444444
123+
444444444444L444
124+
44444444D4411444
125+
444444444441L144
126+
4444444444444444
127+
4444444444444444
128+
44444444444D4444
129+
444D444444D44444
130+
44444444444D4444
131+
4444444444444444
132+
4444444444444444
133+
4414444444444444
134+
4144D4444D444444
135+
444D444444444444
136+
4444444444444444
137+
4444444444444444`],
138+
);
139+
140+
const song = tune`
141+
500,
142+
500: C5~500 + E5^500 + G4/500,
143+
500: A4~500,
144+
500: B4^500,
145+
500: C5~500 + E5^500 + G4/500,
146+
500,
147+
500: D5~500 + F5^500 + A4/500,
148+
500: G4~500,
149+
500: F4^500,
150+
500: E5~500 + G5^500 + C5/500,
151+
500,
152+
500: C5~500 + E5^500,
153+
500: D5/500,
154+
500: E5~500 + G5^500,
155+
500: F5~500,
156+
500: G5^500,
157+
500: A5~500 + E5/500,
158+
500,
159+
500: G5-500 + B5-500,
160+
500,
161+
500: E5~500 + G5^500,
162+
1000,
163+
500: C5~500 + E5^500 + G4/500,
164+
500: B4~500,
165+
500: A4^500,
166+
500: G4/500,
167+
500: C5~500,
168+
2000`;
169+
const playback = playTune(song, Infinity);
170+
171+
const pewSound = tune`
172+
254.23728813559322: B5^254.23728813559322,
173+
7881.35593220339`;
174+
const deathSound = tune`
175+
500,
176+
500: C5~500 + G4/500,
177+
500: A4~500 + F4/500,
178+
500: F4~500 + E4/500,
179+
500: E4~500 + D4/500,
180+
500: E4~500 + C4/500,
181+
500: C4~500,
182+
500: C4~500,
183+
12000`;
184+
185+
setBackground(background);
186+
setSolids([]);
187+
188+
let gameOver = false;
189+
let playerHealth = 100;
190+
let wave = 0;
191+
const swordLifetimes = new Map();
192+
193+
const levels = [
194+
map`
195+
e..............
196+
...............
197+
...............
198+
...............
199+
...............
200+
...............
201+
...............
202+
.......p.......
203+
...............
204+
...............
205+
...............
206+
...............
207+
...............
208+
...............
209+
..............e`
210+
];
211+
212+
setMap(levels[0]);
213+
214+
setPushables({
215+
[player]: []
216+
});
217+
218+
onInput("w", () => movePlayer(0, -1));
219+
onInput("s", () => movePlayer(0, 1));
220+
onInput("a", () => movePlayer(-1, 0));
221+
onInput("d", () => movePlayer(1, 0));
222+
223+
onInput("i", () => throwSword(0, -1));
224+
onInput("j", () => throwSword(-1, 0));
225+
onInput("k", () => throwSword(0, 1));
226+
onInput("l", () => throwSword(1, 0));
227+
228+
function throwSword(x, y) {
229+
if (gameOver) return;
230+
231+
// Check cooldown
232+
const currentTime = Date.now();
233+
if (currentTime - lastSwordThrow < 250) {
234+
return; // Sword is still on cooldown
235+
}
236+
playTune(pewSound);
237+
238+
const playerPos = getFirst(player);
239+
const swordType = x === 0 && y === -1 ? swordUp :
240+
x === 0 && y === 1 ? swordDown :
241+
x === -1 && y === 0 ? swordLeft :
242+
x === 1 && y === 0 ? swordRight : null;
243+
if (swordType) {
244+
const sword = addSprite(playerPos.x, playerPos.y, swordType);
245+
swordLifetimes.set(sword, 5); // Swords last for 5 moves
246+
lastSwordThrow = currentTime; // Update last throw time
247+
}
248+
}
249+
250+
function movePlayer(x, y) {
251+
if (gameOver) return;
252+
const playerPos = getFirst(player);
253+
playerPos.x += x;
254+
playerPos.y += y;
255+
}
256+
257+
function spawnEnemies() {
258+
for (let i = 0; i < Math.ceil(wave / 3 + Math.random() * 4); i++) { // Increase enemies as waves progress
259+
const x = Math.floor(Math.random() * width());
260+
const y = Math.floor(Math.random() * height());
261+
if (x != getFirst(player).x && y != getFirst(player).y) {
262+
addSprite(x, y, enemy);
263+
}
264+
}
265+
}
266+
267+
function checkSword(sword) {
268+
getAll(enemy).forEach(enemySprite => {
269+
if (sword.x === enemySprite.x && sword.y === enemySprite.y) {
270+
enemySprite.remove();
271+
sword.remove();
272+
swordLifetimes.delete(sword);
273+
}
274+
});
275+
}
276+
277+
function moveSwords() {
278+
const directions = [
279+
{ dx: 0, dy: -1 },
280+
{ dx: 0, dy: 1 },
281+
{ dx: -1, dy: 0 },
282+
{ dx: 1, dy: 0 }
283+
];
284+
285+
[swordUp, swordDown, swordLeft, swordRight].forEach((swordType, i) => {
286+
getAll(swordType).forEach(sword => {
287+
checkSword(sword);
288+
sword.x += directions[i].dx;
289+
sword.y += directions[i].dy;
290+
291+
if (sword.x <= 0 || sword.x >= width() - 1 || sword.y <= 0 || sword.y >= height() - 1) {
292+
sword.remove();
293+
swordLifetimes.delete(sword);
294+
}
295+
296+
if (swordLifetimes.has(sword)) {
297+
swordLifetimes.set(sword, swordLifetimes.get(sword) - 1);
298+
if (swordLifetimes.get(sword) <= 0) {
299+
sword.remove();
300+
swordLifetimes.delete(sword);
301+
}
302+
}
303+
});
304+
});
305+
}
306+
307+
function moveEnemies() {
308+
const playerPos = getFirst(player);
309+
getAll(enemy).forEach(enemySprite => {
310+
const dx = playerPos.x - enemySprite.x;
311+
const dy = playerPos.y - enemySprite.y;
312+
if (Math.abs(dx) > Math.abs(dy)) {
313+
enemySprite.x += Math.sign(dx);
314+
} else {
315+
enemySprite.y += Math.sign(dy);
316+
}
317+
});
318+
}
319+
320+
function checkHealth() {
321+
const playerPos = getFirst(player);
322+
getAll(enemy).forEach(enemySprite => {
323+
if (enemySprite.x === playerPos.x && enemySprite.y === playerPos.y) {
324+
playerHealth -= 5;
325+
playerHealth = Math.max(playerHealth, 0);
326+
}
327+
});
328+
}
329+
330+
function displayHealth() {
331+
if (playerHealth == 0) {
332+
clearText();
333+
addText("Game Over!", { x: 5, y: 6, color: color`9` });
334+
addText(`You lasted ${Math.floor(wave / 5)} waves`, { x: 1, y: 9, color: color`7` });
335+
gameOver = true;
336+
playTune(deathSound);
337+
} else {
338+
clearText();
339+
addText(`Health: ${playerHealth}`, { x: 1, y: 0, color: color`3` });
340+
}
341+
}
342+
343+
displayHealth();
344+
setInterval(() => {
345+
if (gameOver) return;
346+
if (wave % 5 === 0) spawnEnemies(); // Spawn enemies every 5 waves
347+
moveEnemies();
348+
moveSwords();
349+
checkHealth();
350+
displayHealth();
351+
wave++;
352+
}, 1000);

0 commit comments

Comments
 (0)