···
k.pos(0, k.height() - 48),
···
// Create walls around the edge of the map
-
const leftWall = k.add([
···
-
const rightWall = k.add([
···
-
const topWall = k.add([
···
// Create player object with components
const playerObj = k.add([
···
k.scene("gameOver", (score: number) => {
-
k.add([k.rect(k.width(), k.height()), k.color(0, 0, 0), k.opacity(0.7)]);
k.text("GAME OVER", { size: 64 }),
k.pos(k.width() / 2, k.height() / 3),
···
k.text(`Final Score: ${score}`, { size: 36 }),
k.pos(k.width() / 2, k.height() / 2),
···
k.text("RESTART", { size: 24 }),
k.pos(k.width() / 2, (k.height() * 2) / 3),
// Restart on button click
restartBtn.onClick(() => {
···
k.pos(0, k.height() - 48),
···
// Create walls around the edge of the map
···
+
let rightWall = k.add([
···
···
+
// Handle window resize
+
ground.width = k.width();
+
ground.pos.y = k.height() - 48;
+
if (leftWall.exists()) {
+
leftWall.height = k.height();
+
if (rightWall.exists()) {
+
rightWall.height = k.height();
+
rightWall.pos.x = k.width();
+
if (topWall.exists()) {
+
topWall.width = k.width();
// Create player object with components
const playerObj = k.add([
···
k.scene("gameOver", (score: number) => {
+
let background = k.add([k.rect(k.width(), k.height()), k.color(0, 0, 0), k.opacity(0.7)]);
+
let gameOverText = k.add([
k.text("GAME OVER", { size: 64 }),
k.pos(k.width() / 2, k.height() / 3),
···
+
let scoreDisplay = k.add([
k.text(`Final Score: ${score}`, { size: 36 }),
k.pos(k.width() / 2, k.height() / 2),
···
+
let restartText = k.add([
k.text("RESTART", { size: 24 }),
k.pos(k.width() / 2, (k.height() * 2) / 3),
+
// Handle window resize
+
if (background.exists()) {
+
background.width = k.width();
+
background.height = k.height();
+
// Update game over text position
+
if (gameOverText.exists()) {
+
gameOverText.pos.x = k.width() / 2;
+
gameOverText.pos.y = k.height() / 3;
+
// Update score display position
+
if (scoreDisplay.exists()) {
+
scoreDisplay.pos.x = k.width() / 2;
+
scoreDisplay.pos.y = k.height() / 2;
+
// Update restart button position
+
if (restartBtn.exists()) {
+
restartBtn.pos.x = k.width() / 2;
+
restartBtn.pos.y = (k.height() * 2) / 3;
+
// Update restart text position
+
if (restartText.exists()) {
+
restartText.pos.x = k.width() / 2;
+
restartText.pos.y = (k.height() * 2) / 3;
// Restart on button click
restartBtn.onClick(() => {