···
41
-
const ground = k.add([
41
+
let ground = k.add([
k.pos(0, k.height() - 48),
···
// Create walls around the edge of the map
52
-
const leftWall = k.add([
52
+
let leftWall = k.add([
···
63
-
const rightWall = k.add([
63
+
let rightWall = k.add([
···
74
-
const topWall = k.add([
74
+
let topWall = k.add([
···
84
+
// Handle window resize
87
+
if (ground.exists()) {
88
+
ground.width = k.width();
89
+
ground.pos.y = k.height() - 48;
93
+
if (leftWall.exists()) {
94
+
leftWall.height = k.height();
97
+
// Update right wall
98
+
if (rightWall.exists()) {
99
+
rightWall.height = k.height();
100
+
rightWall.pos.x = k.width();
104
+
if (topWall.exists()) {
105
+
topWall.width = k.width();
// Create player object with components
const playerObj = k.add([
···
k.scene("gameOver", (score: number) => {
340
-
k.add([k.rect(k.width(), k.height()), k.color(0, 0, 0), k.opacity(0.7)]);
365
+
let background = k.add([k.rect(k.width(), k.height()), k.color(0, 0, 0), k.opacity(0.7)]);
368
+
let gameOverText = k.add([
k.text("GAME OVER", { size: 64 }),
k.pos(k.width() / 2, k.height() / 3),
···
376
+
let scoreDisplay = k.add([
k.text(`Final Score: ${score}`, { size: 36 }),
k.pos(k.width() / 2, k.height() / 2),
···
394
+
let restartText = k.add([
k.text("RESTART", { size: 24 }),
k.pos(k.width() / 2, (k.height() * 2) / 3),
401
+
// Handle window resize
403
+
// Update background
404
+
if (background.exists()) {
405
+
background.width = k.width();
406
+
background.height = k.height();
409
+
// Update game over text position
410
+
if (gameOverText.exists()) {
411
+
gameOverText.pos.x = k.width() / 2;
412
+
gameOverText.pos.y = k.height() / 3;
415
+
// Update score display position
416
+
if (scoreDisplay.exists()) {
417
+
scoreDisplay.pos.x = k.width() / 2;
418
+
scoreDisplay.pos.y = k.height() / 2;
421
+
// Update restart button position
422
+
if (restartBtn.exists()) {
423
+
restartBtn.pos.x = k.width() / 2;
424
+
restartBtn.pos.y = (k.height() * 2) / 3;
427
+
// Update restart text position
428
+
if (restartText.exists()) {
429
+
restartText.pos.x = k.width() / 2;
430
+
restartText.pos.y = (k.height() * 2) / 3;
// Restart on button click
restartBtn.onClick(() => {