Code edit (1 edits merged)
Please save this source code
User prompt
Let's add instructions to the bottom of the page that says diffuse the bomb by getting perfect timing at point zero zero ten times.
User prompt
Hide the final score on the Game Over pop-up.
User prompt
When you get a perfect score, the diffuse line should increment to 10 out of 10.
User prompt
It should also show the remaining time when you get a perfect score.
User prompt
It's not showing the you win text though either when you get a perfect score.
User prompt
Do you know why when you get a perfect score, it's not showing the you win screen with the award sound?
User prompt
Getting a perfect score will win the game for the player immediately.
User prompt
The timer should stop when the player wins the game, and display the remaining time.
User prompt
When all 10 fuses are diffused, the player wins the game.
User prompt
The player wins the game when all 10 fuses have been diffused.
User prompt
Player gets one fuse every time they get a hit.
User prompt
When the player gets a perfect timing, they automatically defuse all 10 fuses and the game is over with them winning.
User prompt
Let's add a score to the game over screen. This score will be equal to the time remaining.
User prompt
When the player loses, the lose text should appear as remaining time, colon, 0.00.
User prompt
When the player loses, ensure the remaining time shows as 0.00.
User prompt
The remaining time displayed should never show anything less than 0.00.
Code edit (1 edits merged)
Please save this source code
User prompt
Let's increase the scale of the explosion by five times.
User prompt
When the player loses, let's display the explosion image in the center of the screen.
User prompt
Let's add a new shape called Explosion.
User prompt
When the player loses, let's hide the dynamite image and the stopwatch image and the stopwatch text.
Code edit (2 edits merged)
Please save this source code
User prompt
Let's decrease the Opacity of the dynamite image and make it 80% opaque.
Code edit (1 edits merged)
Please save this source code
/**** * Initialize Game ****/ // No assets are needed for this game // No classes are needed for this game var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize sound assets // Initialize variables var winTxt = null; var loseTxt = null; var startTime = null; var elapsedTime = 0; var timerTxt = null; var gameStarted = false; var progressBar = null; var progressBarWidth = 2048; // Full width of the screen var progressBarHeight = 50; // Height of the progress bar // Add dynamite image behind the stopwatch image var dynamiteImage = LK.getAsset('dynamite', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 450 / 215.57 * 2, scaleY: 450 / 215.57 * 2, // Increase size by three times alpha: 0.5 // Set opacity to 80% }); game.addChild(dynamiteImage); // Add stopwatch image to the game var stopwatchImage = LK.getAsset('stopwatchImage', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); game.addChild(stopwatchImage); // Create a progress bar progressBar = LK.getAsset('stopwatch', { anchorX: 1.0, anchorY: 0.0, x: 2048, // Start from the right edge y: 0, // Top of the screen width: progressBarWidth, height: progressBarHeight, color: 0xff0000 // Red color for timer progress }); game.addChild(progressBar); // Create a defuse bar for points var defuseBar = LK.getAsset('diffuseLine', { anchorX: 0.0, anchorY: 0.0, x: 0, // Start from the left edge y: 50, // Just below the top of the screen width: 0, // Start with zero width height: progressBarHeight }); game.addChild(defuseBar); // Create a text object to display the timer timerTxt = new Text2('0.00', { size: 150, fill: "#ffffff", // Change text color to white stroke: "#000000", // Add black stroke strokeThickness: 10, // Set stroke thickness to thick font: "Arial" // Set font to Arial }); timerTxt.anchor.set(0.5, 0.5); timerTxt.x = 2048 / 2; timerTxt.y = 2732 / 2 + 40; game.addChild(timerTxt); // Create a text object to display the score var scoreTxt = new Text2('Defused: 0 of 10', { size: 100, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); startTime = Date.now(); gameStarted = true; // Check the elapsed time on mouse up game.down = function (x, y, obj) { if (gameStarted) { elapsedTime = 60 - (Date.now() - startTime) / 1000; timerTxt.setText(elapsedTime.toFixed(2)); if (Math.abs(elapsedTime - Math.round(elapsedTime)) <= 0.01) { LK.effects.flashScreen(0xffff00, 500); // Flash yellow for exact time LK.getSound('hit').play(); // Play the 'hit' sound //LK.setScore(LK.getScore() + 0); // Increment score by 10 scoreTxt.setText('Fuses: ' + LK.getScore() + ' out of 10'); // Update score display } else if (Math.abs(elapsedTime - Math.round(elapsedTime)) <= 0.1) { LK.effects.flashScreen(0x00ff00, 500); // Flash green to simulate fireworks LK.getSound('hit').play(); // Play the 'hit' sound //LK.setScore(LK.getScore() + 0); // Increment score scoreTxt.setText('Fuses: ' + LK.getScore() + ' out of 10'); // Update score display } else { startTime -= 5000; // Adjust startTime to deduct five seconds persistently timerTxt.setText(elapsedTime.toFixed(2)); // Update timer display LK.effects.flashScreen(0xff0000, 500); // Flash red for negative effect LK.getSound('miss').play(); // Play the 'miss' sound } } }; // Update the timer every game tick game.update = function () { if (gameStarted) { elapsedTime = 60 - (Date.now() - startTime) / 1000; timerTxt.setText(elapsedTime.toFixed(2)); // Update progress bar width progressBar.width = progressBarWidth * (1 - elapsedTime / 60); // Update defuse bar width with 10 segments defuseBar.width = progressBarWidth * (LK.getScore() / 10); if (LK.getScore() >= 10) { // game.setBackgroundColor(0x00ff00); // Removed green background effect if (!winTxt) { // Hide dynamite and stopwatch images and text dynamiteImage.visible = false; stopwatchImage.visible = false; timerTxt.visible = false; LK.getSound('win').play(); // Play the 'win' sound winTxt = new Text2('You Win!', { size: 200, fill: "#ffffff" }); winTxt.anchor.set(0.5, 0.0); winTxt.x = 2048 / 2; winTxt.y = 300; // Position near the top of the screen game.addChild(winTxt); // Display remaining time var remainingTimeTxt = new Text2('Remaining Time: 0.00s', { size: 100, fill: "#ffffff" }); remainingTimeTxt.anchor.set(0.5, 0.0); remainingTimeTxt.x = 2048 / 2; remainingTimeTxt.y = 700; // Lower the position by 300 pixels game.addChild(remainingTimeTxt); } LK.setTimeout(function () { LK.showGameOver(); // End game }, 2000); // Delay by 2000ms or 2 seconds gameStarted = false; } else if (elapsedTime <= 0) { if (!loseTxt) { // Hide dynamite and stopwatch images and text dynamiteImage.visible = false; stopwatchImage.visible = false; timerTxt.visible = false; // Display explosion image in the center of the screen var explosionImage = LK.getAsset('explosion', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 5, scaleY: 5 }); game.addChild(explosionImage); // Display remaining time var remainingTimeTxt = new Text2('Remaining Time: ' + elapsedTime.toFixed(2), { size: 100, fill: "#ffffff" }); remainingTimeTxt.anchor.set(0.5, 0.0); remainingTimeTxt.x = 2048 / 2; remainingTimeTxt.y = 700; // Lower the position by 300 pixels game.addChild(remainingTimeTxt); LK.getSound('lose').play(); // Play the 'lose' sound loseTxt = new Text2('BOOM!', { size: 200, fill: "#ffffff" }); loseTxt.anchor.set(0.5, 0.0); loseTxt.x = 2048 / 2; loseTxt.y = 300; // Position near the top of the screen game.addChild(loseTxt); } LK.setTimeout(function () { LK.showGameOver(); // End game }, 2000); // Delay by 2000ms or 2 seconds gameStarted = false; } } }; // Initialize stopwatch image asset
===================================================================
--- original.js
+++ change.js
@@ -169,9 +169,9 @@
scaleY: 5
});
game.addChild(explosionImage);
// Display remaining time
- var remainingTimeTxt = new Text2('Remaining Time: 0.00', {
+ var remainingTimeTxt = new Text2('Remaining Time: ' + elapsedTime.toFixed(2), {
size: 100,
fill: "#ffffff"
});
remainingTimeTxt.anchor.set(0.5, 0.0);
cartoon dynamite. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
explosion. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8-bit crowd of police and others cheer. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.