User prompt
game over screen should also display the number of miles and coins collected at the moment the game is over
User prompt
once game over screen is up, disable all hitboxes so nothing can collide withnothing
User prompt
add a black background to game over screen
User prompt
game over screen background should not be transparent
User prompt
when gameover screen is up, player should no be moved anymore
User prompt
when game over screen is up, intead of just showing the miles, make a counter from 0 to reach to the number that updates very very gast
User prompt
on game over screen, below miles and coins add a final score result.
User prompt
make game over screen last 5 seconds
User prompt
final score should be a mix of miles and be increased depending on how many coins where colleceted
User prompt
game over screen should first show miles, once they are loaded, show coins, and once this two are complete, show final score
User prompt
multiply coins by 100 to add to final score
User prompt
make gamme over screen cover all screen
User prompt
game overr screen should allways be on top of any element
User prompt
stop spawning obstacles on game over
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'some')' in or related to this line: 'if (player && !player.isJumping && player.hitbox.some(function (hitbox) {' Line Number: 1582
User prompt
add more space between game over text and miles and coins and final score
User prompt
play destroy sound when game over screen appears
User prompt
game over backgorund should be blacck
User prompt
game over text should be the same green used in the game tint
User prompt
destroye player into particles when game over screen is up
User prompt
hided playe when game over is up
User prompt
on tick make sure that game over is on the top layer above anything else on the screen
User prompt
if game over is up, empty array for obstacles
User prompt
when game over is up, use a new spawnorder that spawns 0 obstacles
User prompt
when game over is up, obsacles coins and powerups should stop moving
===================================================================
--- original.js
+++ change.js
@@ -1353,27 +1353,29 @@
mode2Button.update();
// Update miles traveled
milesTraveled += gameSpeed / 30; // Increase the speed at which miles are counted
milesTxt.setText(Math.floor(milesTraveled));
- if (!gameStarted) {
+ if (!gameStarted || gameOverScreen) {
// Update starfield
return;
}
- // Update lane separators
- for (var i = 0; i < laneSeparators.length; i++) {
- laneSeparators[i].update();
- laneSeparators[i].children[0].height = 2732; // Ensure the height covers the entire screen height
- }
- // Update player
- player.update();
- // Increase game speed and decrease global spawn interval over time
- if (LK.ticks % 600 == 0) {
- // Increase speed every 10 seconds
- gameSpeed *= 1.05; // Increase speed by 5%
- // Decrease global spawn interval to make spawns more frequent
- globalSpawnInterval = Math.max(30, globalSpawnInterval - 10); // Ensure interval doesn't go below 30 frames (0.5 seconds)
- }
- // Update obstacles, coins, and powerups
+};
+// Update lane separators
+for (var i = 0; i < laneSeparators.length; i++) {
+ laneSeparators[i].update();
+ laneSeparators[i].children[0].height = 2732; // Ensure the height covers the entire screen height
+}
+// Update player
+player.update();
+// Increase game speed and decrease global spawn interval over time
+if (LK.ticks % 600 == 0) {
+ // Increase speed every 10 seconds
+ gameSpeed *= 1.05; // Increase speed by 5%
+ // Decrease global spawn interval to make spawns more frequent
+ globalSpawnInterval = Math.max(30, globalSpawnInterval - 10); // Ensure interval doesn't go below 30 frames (0.5 seconds)
+}
+// Update obstacles, coins, and powerups
+if (!gameOverScreen) {
for (var i = powerups.length - 1; i >= 0; i--) {
powerups[i].y += gameSpeed;
powerups[i].update();
if (player && !player.isJumping && player.hitbox.some(function (hitbox) {
@@ -1392,192 +1394,197 @@
powerups[i].destroy();
powerups.splice(i, 1);
}
}
- for (var i = obstacles.length - 1; i >= 0; i--) {
- obstacles[i].y += gameSpeed;
- obstacles[i].update();
- if (!player.isJumping && player.hitbox && player.hitbox.some(function (hitbox) {
- return checkBoundingBoxCollision(hitbox, obstacles[i]) && obstacles[i].hitbox !== null;
- })) {
- if (player.isInvulnerable) {
- // Spawn particles
- for (var j = 0; j < 20; j++) {
- // Increase the number of particles to 20
- var particle = new Particle();
- particle.x = obstacles[i].x;
- particle.y = obstacles[i].y;
- particle.scale.set(1.5); // Increase the size of the particles
- particle.tint = 0x82ee3a; // Set particle color to #82ee3a
- game.addChild(particle);
+ if (!gameOverScreen) {
+ for (var i = obstacles.length - 1; i >= 0; i--) {
+ obstacles[i].y += gameSpeed;
+ obstacles[i].update();
+ if (!player.isJumping && player.hitbox && player.hitbox.some(function (hitbox) {
+ return checkBoundingBoxCollision(hitbox, obstacles[i]) && obstacles[i].hitbox !== null;
+ })) {
+ if (player.isInvulnerable) {
+ // Spawn particles
+ for (var j = 0; j < 20; j++) {
+ // Increase the number of particles to 20
+ var particle = new Particle();
+ particle.x = obstacles[i].x;
+ particle.y = obstacles[i].y;
+ particle.scale.set(1.5); // Increase the size of the particles
+ particle.tint = 0x82ee3a; // Set particle color to #82ee3a
+ game.addChild(particle);
+ }
+ // Play destroy sound when an obstacle is destroyed by the player with the shield
+ LK.getSound('destroy').play();
+ obstacles[i].destroy();
+ obstacles.splice(i, 1);
+ } else {
+ gameOverScreen = new GameOverScreen();
+ game.addChildAt(gameOverScreen, game.children.length);
+ // Disable all hitboxes
+ player.hitbox = null;
+ if (leftPlayer) {
+ leftPlayer.hitbox = null;
+ }
+ if (rightPlayer) {
+ rightPlayer.hitbox = null;
+ }
+ for (var k = 0; k < obstacles.length; k++) {
+ obstacles[k].hitbox = null;
+ }
+ for (var l = 0; l < coins.length; l++) {
+ coins[l].hitbox = null;
+ }
+ for (var m = 0; m < powerups.length; m++) {
+ powerups[m].hitbox = null;
+ }
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 5000);
}
- // Play destroy sound when an obstacle is destroyed by the player with the shield
- LK.getSound('destroy').play();
- obstacles[i].destroy();
- obstacles.splice(i, 1);
- } else {
- gameOverScreen = new GameOverScreen();
- game.addChildAt(gameOverScreen, game.children.length);
- // Disable all hitboxes
- player.hitbox = null;
- if (leftPlayer) {
- leftPlayer.hitbox = null;
+ }
+ }
+ // Handle obstacle spawning based on configuration
+ obstacleSpawnTimer++;
+ if (!gameOverScreen && obstacleSpawnTimer >= obstacleSpawnOrder[currentObstacleIndex].interval) {
+ var obstacleType = obstacleSpawnOrder[currentObstacleIndex].type;
+ if (obstacleType === 'BigObstacle') {
+ spawnBigObstacle();
+ } else if (obstacleType === 'LineObstacle') {
+ spawnObstacle();
+ } else if (obstacleType === 'Obstacle') {
+ spawnObstacle();
+ } else if (obstacleType === 'SmallObstacle') {
+ spawnSmallObstacle();
+ } else if (obstacleType === 'SmallObstacleLeftMiddleCoinRight') {
+ spawnSmallObstacleLeftMiddleCoinRight();
+ } else if (obstacleType === 'SmallObstacleRightCenterCoinLeft') {
+ spawnSmallObstacleRightCenterCoinLeft();
+ } else if (obstacleType === 'SmallObstacleCenterCoinLeftPowerUpRight') {
+ spawnSmallObstacleCenterCoinLeftPowerUpRight();
+ } else if (obstacleType === 'TextObstacle') {
+ var customText = obstacleSpawnOrder[currentObstacleIndex].text || 'Default Text';
+ spawnTextObstacle(customText);
+ } else if (obstacleType === 'ObstacleLine') {
+ spawnObstacleLine();
+ } else if (obstacleType === 'SmallObstaclesSidesCoinMiddle') {
+ spawnSmallObstaclesSidesCoinMiddle();
+ } else if (obstacleType === 'SmallObstacleCenterCoinSides') {
+ spawnSmallObstacleCenterCoinSides();
+ } else if (obstacleType === 'SmallObstacleMiddlePowerUpLeftCoinRight') {
+ spawnSmallObstacleMiddlePowerUpLeftCoinRight();
+ } else if (obstacleType === 'PowerUpCenterLane') {
+ spawnPowerUpCenterLane();
+ }
+ currentObstacleIndex++;
+ if (currentObstacleIndex >= obstacleSpawnOrder.length) {
+ currentObstacleIndex = 0;
+ if (obstacleSpawnOrder === obstacleSpawnOrderRandom) {
+ obstacleSpawnOrder = obstacleSpawnOrderRandom.sort(function () {
+ return Math.random() - 0.5;
+ });
+ } else {
+ obstacleSpawnOrder = obstacleSpawnOrderRandom;
}
- if (rightPlayer) {
- rightPlayer.hitbox = null;
- }
- for (var k = 0; k < obstacles.length; k++) {
- obstacles[k].hitbox = null;
- }
- for (var l = 0; l < coins.length; l++) {
- coins[l].hitbox = null;
- }
- for (var m = 0; m < powerups.length; m++) {
- powerups[m].hitbox = null;
- }
- LK.setTimeout(function () {
- LK.showGameOver();
- }, 5000);
}
+ obstacleSpawnTimer = 0;
}
- }
- // Handle obstacle spawning based on configuration
- obstacleSpawnTimer++;
- if (obstacleSpawnTimer >= obstacleSpawnOrder[currentObstacleIndex].interval) {
- var obstacleType = obstacleSpawnOrder[currentObstacleIndex].type;
- if (obstacleType === 'BigObstacle') {
- spawnBigObstacle();
- } else if (obstacleType === 'LineObstacle') {
- spawnObstacle();
- } else if (obstacleType === 'Obstacle') {
- spawnObstacle();
- } else if (obstacleType === 'SmallObstacle') {
- spawnSmallObstacle();
- } else if (obstacleType === 'SmallObstacleLeftMiddleCoinRight') {
- spawnSmallObstacleLeftMiddleCoinRight();
- } else if (obstacleType === 'SmallObstacleRightCenterCoinLeft') {
- spawnSmallObstacleRightCenterCoinLeft();
- } else if (obstacleType === 'SmallObstacleCenterCoinLeftPowerUpRight') {
- spawnSmallObstacleCenterCoinLeftPowerUpRight();
- } else if (obstacleType === 'TextObstacle') {
- var customText = obstacleSpawnOrder[currentObstacleIndex].text || 'Default Text';
- spawnTextObstacle(customText);
- } else if (obstacleType === 'ObstacleLine') {
- spawnObstacleLine();
- } else if (obstacleType === 'SmallObstaclesSidesCoinMiddle') {
- spawnSmallObstaclesSidesCoinMiddle();
- } else if (obstacleType === 'SmallObstacleCenterCoinSides') {
- spawnSmallObstacleCenterCoinSides();
- } else if (obstacleType === 'SmallObstacleMiddlePowerUpLeftCoinRight') {
- spawnSmallObstacleMiddlePowerUpLeftCoinRight();
- } else if (obstacleType === 'PowerUpCenterLane') {
- spawnPowerUpCenterLane();
- }
- currentObstacleIndex++;
- if (currentObstacleIndex >= obstacleSpawnOrder.length) {
- currentObstacleIndex = 0;
- if (obstacleSpawnOrder === obstacleSpawnOrderRandom) {
- obstacleSpawnOrder = obstacleSpawnOrderRandom.sort(function () {
- return Math.random() - 0.5;
- });
- } else {
- obstacleSpawnOrder = obstacleSpawnOrderRandom;
+ // Handle split duration and animate back to center
+ if (splitTimer > 0) {
+ splitTimer--;
+ if (splitTimer === 0) {
+ // Animate leftPlayer and rightPlayer back to the center
+ var centerX = player.x;
+ var animationDuration = 20; // Duration in frames (0.33 seconds at 60 FPS)
+ // Initialize update functions after adding to game
+ leftPlayer.update = function () {
+ if (animationDuration > 0) {
+ leftPlayer.x += (centerX - leftPlayer.x) * 0.1; // Smooth movement using linear interpolation
+ animationDuration--;
+ } else {
+ leftPlayer.destroy();
+ leftPlayer = null;
+ player.visible = true;
+ player.hitbox = [player]; // Reset player hitbox to original player
+ // Play swipe sound when player merges back together
+ LK.getSound('swipe').play();
+ }
+ // Add any specific update logic for LeftPlayer here
+ if (LK.ticks % 4 == 0) {
+ var trail = new Trail();
+ trail.scale.x = 0.5;
+ trail.scale.y = 0.5;
+ trail.x = leftPlayer ? leftPlayer.x : 0;
+ trail.y = leftPlayer.y + leftPlayer.height / 2;
+ game.addChildAt(trail, game.getChildIndex(leftPlayer));
+ }
+ };
+ rightPlayer.update = function () {
+ if (animationDuration > 0) {
+ rightPlayer.x += (centerX - rightPlayer.x) * 0.1; // Smooth movement using linear interpolation
+ animationDuration--;
+ } else {
+ rightPlayer.destroy();
+ rightPlayer = null;
+ player.visible = true;
+ player.hitbox = [player]; // Reset player hitbox to original player
+ // Play swipe sound when player merges back together
+ LK.getSound('swipe').play();
+ }
+ // Add any specific update logic for RightPlayer here
+ if (LK.ticks % 4 == 0) {
+ var trail = new Trail();
+ trail.scale.x = 0.5;
+ trail.scale.y = 0.5;
+ trail.x = rightPlayer ? rightPlayer.x : 0;
+ trail.y = rightPlayer.y + rightPlayer.height / 2;
+ game.addChildAt(trail, game.getChildIndex(rightPlayer));
+ }
+ };
}
}
- obstacleSpawnTimer = 0;
- }
- // Handle split duration and animate back to center
- if (splitTimer > 0) {
- splitTimer--;
- if (splitTimer === 0) {
- // Animate leftPlayer and rightPlayer back to the center
- var centerX = player.x;
- var animationDuration = 20; // Duration in frames (0.33 seconds at 60 FPS)
- // Initialize update functions after adding to game
- leftPlayer.update = function () {
- if (animationDuration > 0) {
- leftPlayer.x += (centerX - leftPlayer.x) * 0.1; // Smooth movement using linear interpolation
- animationDuration--;
- } else {
- leftPlayer.destroy();
- leftPlayer = null;
- player.visible = true;
- player.hitbox = [player]; // Reset player hitbox to original player
- // Play swipe sound when player merges back together
- LK.getSound('swipe').play();
+ if (!gameOverScreen) {
+ for (var i = coins.length - 1; i >= 0; i--) {
+ coins[i].y += gameSpeed;
+ coins[i].update();
+ if (player && !player.isJumping && player.hitbox.some(function (hitbox) {
+ return checkBoundingBoxCollision(hitbox, coins[i]);
+ })) {
+ score += 1;
+ scoreTxt.setText(score);
+ // Play bling sound
+ LK.getSound('bling').play();
+ // Spawn particles
+ for (var j = 0; j < 10; j++) {
+ var particle = new Particle();
+ particle.x = coins[i].x;
+ particle.y = coins[i].y;
+ particle.tint = coins[i].children[0].tint; // Inherit color from the coin
+ game.addChild(particle);
+ }
+ coins[i].destroy();
+ coins.splice(i, 1);
}
- // Add any specific update logic for LeftPlayer here
- if (LK.ticks % 4 == 0) {
- var trail = new Trail();
- trail.scale.x = 0.5;
- trail.scale.y = 0.5;
- trail.x = leftPlayer ? leftPlayer.x : 0;
- trail.y = leftPlayer.y + leftPlayer.height / 2;
- game.addChildAt(trail, game.getChildIndex(leftPlayer));
- }
- };
- rightPlayer.update = function () {
- if (animationDuration > 0) {
- rightPlayer.x += (centerX - rightPlayer.x) * 0.1; // Smooth movement using linear interpolation
- animationDuration--;
- } else {
- rightPlayer.destroy();
- rightPlayer = null;
- player.visible = true;
- player.hitbox = [player]; // Reset player hitbox to original player
- // Play swipe sound when player merges back together
- LK.getSound('swipe').play();
- }
- // Add any specific update logic for RightPlayer here
- if (LK.ticks % 4 == 0) {
- var trail = new Trail();
- trail.scale.x = 0.5;
- trail.scale.y = 0.5;
- trail.x = rightPlayer ? rightPlayer.x : 0;
- trail.y = rightPlayer.y + rightPlayer.height / 2;
- game.addChildAt(trail, game.getChildIndex(rightPlayer));
- }
- };
+ }
}
- }
- for (var i = coins.length - 1; i >= 0; i--) {
- coins[i].y += gameSpeed;
- coins[i].update();
- if (player && !player.isJumping && player.hitbox.some(function (hitbox) {
- return checkBoundingBoxCollision(hitbox, coins[i]);
- })) {
- score += 1;
- scoreTxt.setText(score);
- // Play bling sound
- LK.getSound('bling').play();
- // Spawn particles
- for (var j = 0; j < 10; j++) {
- var particle = new Particle();
- particle.x = coins[i].x;
- particle.y = coins[i].y;
- particle.tint = coins[i].children[0].tint; // Inherit color from the coin
- game.addChild(particle);
+ for (var i = powerups.length - 1; i >= 0; i--) {
+ powerups[i].y += gameSpeed;
+ powerups[i].update();
+ if (player && !player.isJumping && player.hitbox.some(function (hitbox) {
+ return checkBoundingBoxCollision(hitbox, powerups[i]);
+ })) {
+ player.isInvulnerable = true;
+ player.invulnerableTimer = 600; // 10 seconds at 60 FPS
+ LK.getSound('powerup').play(); // Play powerup sound
+ LK.getSound('powerup').play(); // Play powerup sound
+ powerups[i].destroy();
+ powerups.splice(i, 1);
}
- coins[i].destroy();
- coins.splice(i, 1);
}
}
- for (var i = powerups.length - 1; i >= 0; i--) {
- powerups[i].y += gameSpeed;
- powerups[i].update();
- if (player && !player.isJumping && player.hitbox.some(function (hitbox) {
- return checkBoundingBoxCollision(hitbox, powerups[i]);
- })) {
- player.isInvulnerable = true;
- player.invulnerableTimer = 600; // 10 seconds at 60 FPS
- LK.getSound('powerup').play(); // Play powerup sound
- LK.getSound('powerup').play(); // Play powerup sound
- powerups[i].destroy();
- powerups.splice(i, 1);
- }
- }
// Automatic spawning of obstacles, coins, and powerups has been removed
-};
+}
+;
// Function to spawn SmallObstacle
function spawnSmallObstacle() {
var smallObstacle = new SmallObstacle();
smallObstacle.x = 2048 / 2; // Center the SmallObstacle
cartoon white circle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon light blue circle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon white square. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
black rectangle