User prompt
No, let's do something more rigid, something more analog looking for the font.
User prompt
Let's change the font to something that looks more digital, like an LCD font.
User prompt
Let's create a white stroke around the timer and make the timer text black.
User prompt
Right let's do that
User prompt
The win message and boom message should be shown at the top of the screen when the game is over.
User prompt
Let's show the seconds remaining at the top of the screen when the game ends.
User prompt
Please fix the bug: 'ReferenceError: winTxt is not defined' in or related to this line: 'if (!winTxt) {' Line Number: 111
User prompt
We should do something special if the user gets the exact time to the hundredth of the second. So for this special case, we should flash the screen yellow and give them 10 points.
User prompt
If the user gets the exact time to the hundredth of a second, they should automatically win the game and get 10 points.
User prompt
The timer should stop when the user presses down on the mouse button and not when they release it.
User prompt
Please fix the bug: 'ReferenceError: loseTxt is not defined' in or related to this line: 'if (!loseTxt) {' Line Number: 119
User prompt
I'm still not seeing the win or boom on screen. Do you know why?
User prompt
Please disconnect U-Win and Boom from other elements on the screen. Their anchors should be independent of those, and they should appear vertically near the top and horizontally center on the screen.
User prompt
please correct that
User prompt
It needs to go in the other direction. It's adding rather than subtracting total time.
User prompt
Let's use persistent deduction.
User prompt
If the user clicks on the wrong time, when the screen flashes red, it should also deduct five seconds from the timer that is counting down.
User prompt
The you win text is not centered. It should be directly beneath the score
User prompt
Let's remove the green effect at the end when you win.
User prompt
Instead of minusing a point for getting the wrong time, let's deduct one second of the timer.
Code edit (1 edits merged)
Please save this source code
User prompt
The you win and you lose text should be center justified so they appear in the center horizontal section of the screen.
User prompt
If the player loses and the time runs out, they should get the message, you lose, the bomb went off, right below the score. Size 200, centered at the top of the screen, 200 pixels from the top.
User prompt
Every time the player misses the timer, they should get negative one point, but it should never go below zero. Zero is the lowest amount of points they can get.
User prompt
The you win message is showing up on the far right of the screen. This should be centered right beneath the score.
/****
* 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 variables
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 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
});
game.addChild(progressBar);
// Create a defuse bar for points
var defuseBar = LK.getAsset('stopwatch', {
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,
color: 0x00ff00 // Green color for defuse progress
});
game.addChild(defuseBar);
// Create a text object to display the timer
timerTxt = new Text2('0.00', {
size: 150,
fill: "#ffffff"
});
timerTxt.anchor.set(0.5, 0.5);
timerTxt.x = 2048 / 2;
timerTxt.y = 2732 / 2;
game.addChild(timerTxt);
// Create a text object to display the score
var scoreTxt = new Text2('Score: 0', {
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.up = 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.1) {
LK.effects.flashScreen(0x00ff00, 500); // Flash green to simulate fireworks
LK.setScore(LK.getScore() + 1); // Increment score
scoreTxt.setText('Score: ' + LK.getScore()); // Update score display
} else {
LK.effects.flashScreen(0xff0000, 500); // Flash red for negative effect
}
}
};
// 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); // Set background to green
var winTxt = new Text2('You Win!', {
size: 200,
fill: "#ffffff"
});
winTxt.anchor.set(0.5, 0);
winTxt.x = 2048 / 2;
winTxt.y = scoreTxt.y + scoreTxt.height + 50; // Position beneath the score
LK.gui.top.addChild(winTxt);
LK.showGameOver(); // End game
gameStarted = false;
} else if (elapsedTime <= 0) {
LK.showGameOver(); // End game
gameStarted = false;
}
}
};
// Initialize stopwatch image asset
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.