User prompt
I'm still not hearing it
User prompt
I'm not hearing the hit sound when I hit the target correctly.
User prompt
When the player hits the timer correctly, make the hit sound.
User prompt
Let's create sound assets for miss, hit, win, lose.
User prompt
Please fix the bug: 'TypeError: LK.addChild is not a function' in or related to this line: 'LK.addChild(winTxt);' Line Number: 127
Code edit (4 edits merged)
Please save this source code
User prompt
I don't want the lose text to be a child of any of the other GUID that's already there that should be independent.
Code edit (1 edits merged)
Please save this source code
User prompt
Let's increase the Z axis of the circle so it's visible.
User prompt
Let's place a black circle behind the stopwatch text with a 50% opacity.
User prompt
Let's lower it a little bit more by 10 pixels.
User prompt
Let's lower the Y position of the stopwatch text by 30 pixels.
User prompt
Let's make the stopwatch font white with a black stroke that is thick.
User prompt
Let's make that font bold.
User prompt
Please set that font to Arial.
Code edit (1 edits merged)
Please save this source code
User prompt
Let's change the stopwatch timer font to Impact.
User prompt
Let's change the timer font to Arial Bold.
User prompt
Let's try Ridana.
User prompt
Actually, that's messy. Let's use Arial Bold.
User prompt
Let's use impact.
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
/****
* 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 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 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.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.setScore(LK.getScore() + 10); // 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.setScore(LK.getScore() + 1); // 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
}
}
};
// 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) {
winTxt = new Text2('You Win!', {
size: 100,
fill: "#ffffff"
});
winTxt.anchor.set(0.5, 0.0);
winTxt.x = 2048 / 2;
winTxt.y = 100; // Position near the top of the screen
LK.gui.top.addChild(winTxt);
}
LK.showGameOver(); // End game
gameStarted = false;
} else if (elapsedTime <= 0) {
if (!loseTxt) {
loseTxt = new Text2('BOOM! Time Left: ' + elapsedTime.toFixed(2) + 's', {
size: 100,
fill: "#ffffff"
});
loseTxt.anchor.set(0.5, 0.0);
loseTxt.x = 2048 / 2;
loseTxt.y = 100; // Position near the top of the screen
LK.gui.top.addChild(loseTxt);
}
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.