User prompt
display the level text at all times
User prompt
fix the bug where the Level Text stays at Level 0
User prompt
fix the level text to match the current milestones
User prompt
the level text should always be visible starting with 0
User prompt
fix the text for milestones
User prompt
fix the bug where the level display disappears and is not increased after each milestone
User prompt
for every milestone reached display a distinct text representing each milestone as a Level
User prompt
fix the bug where the stars are not added correctly depending on the milstone
User prompt
there should be 2 star at milestone 10 and 3 star at milestone 20, this logic should be applied for all milestones
User prompt
change the milestones to 10, 20, 30, 40, 50, 60, 70, 80, and 100
User prompt
check why no additional stars are created
User prompt
fix the bug where no additional star is created for the specific score milestone
User prompt
add one star after score 100, after score 200, after score 300, after score 400 and after score 500
User prompt
fix the bug where no additional star is created after every 100 score
User prompt
double the amount of stars after every 100 points
User prompt
add one star after every 100 points
User prompt
fix the bug where new stars are generated before reaching 100 points
User prompt
change the logic to when score reaches 100 to add one star to every 100 points
User prompt
change the amount of stars from double the amount of stars to add one more star
User prompt
after 100 points double stars
User prompt
after 10 points double stars
User prompt
Life Points are not changed to red when mole reaches green surface
User prompt
check bug why life points color are changed to black
User prompt
change all purple colors to blue
User prompt
Change the font of life points and change the color to purple
/****
* Classes
****/
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Mole class to represent each mole in the game
var Mole = Container.expand(function () {
var self = Container.call(this);
var moleGraphics = self.attachAsset('mole', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 2 + 1; // Random speed for each mole
self.visible = false; // Initially not visible
// Method to show the mole
self.show = function () {
self.visible = true;
self.y = 0; // Start from the hole
};
// Method to hide the mole
self.hide = function () {
self.visible = false;
};
// Event handler called when a press happens on element
self.down = function (x, y, obj) {
self.hide();
score++;
scoreTxt.setText('Score: ' + score);
};
// Update method for mole movement
self.update = function () {
if (self.visible) {
self.y += self.speed;
if (self.y > 2000) {
// Change one life point to red
if (lifePoints.length > 0) {
var heart = lifePoints.pop();
heart.tint = 0xff0000; // Change heart color to red
}
// If mole is fully out, hide it
self.hide();
// Ensure life points remain visible
lifePoints.forEach(function (heart) {
if (!game.children.includes(heart)) {
game.addChild(heart);
}
});
// Check if all life points are red (game over condition)
if (lifePoints.length === 0) {
LK.showGameOver(); // Display game over
}
}
}
};
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = (Math.random() * 2 + 1) * 2; // Double the speed for each star
self.visible = false; // Initially not visible
// Method to show the star
self.show = function () {
self.visible = true;
self.y = 0; // Start from the top
};
// Method to hide the star
self.hide = function () {
self.visible = false;
};
// Update method for star movement
self.update = function () {
if (self.visible) {
self.y += self.speed;
if (self.y > 2000) {
// If star is fully out, hide it
self.hide();
// Add a mole when a star reaches the green surface
var mole = new Mole();
mole.x = Math.random() * 2048;
mole.y = 500;
moles.push(mole);
game.addChild(mole);
}
}
};
// Event handler called when a press happens on element
self.down = function (x, y, obj) {
self.hide();
score += 10;
scoreTxt.setText('Score: ' + score);
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb // Light blue background
});
/****
* Game Code
****/
// Game state variables
var score = 0;
var moles = [];
var lifePoints = [];
var hammerCursor;
var isPaused = false;
// Initialize the game board
function initBoard() {
var greenSurface = LK.getAsset('greenSurface', {
anchorX: 0.0,
anchorY: 0.0,
x: 0,
y: 2000
});
game.addChild(greenSurface);
for (var i = 0; i < 1; i++) {
var mole = new Mole();
mole.x = Math.random() * 2048;
mole.y = 500;
moles.push(mole);
game.addChild(mole);
var star = new Star();
star.x = Math.random() * 2048;
star.y = 0;
game.addChild(star);
}
}
// Initialize the game interface
function initInterface() {
// Score display
scoreTxt = new Text2('Score: 0', {
size: 100,
fill: 0x000000,
fontWeight: "bold"
});
scoreTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreTxt);
// Pause/Unpause button
var pauseButton = new Text2('Slowmotion', {
size: 80,
fill: 0xFF4500 // Fiery color
});
pauseButton.anchor.set(0, 1);
pauseButton.stroke = 0x000000; // Black color for the line
pauseButton.strokeThickness = 5; // Thickness of the line
// Life points display
for (var i = 0; i < 3; i++) {
var heart = LK.getAsset('heart', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024 - i * 60,
y: 2366
});
game.addChild(heart); // Add hearts to the game scene
lifePoints.push(heart);
}
// Add "Life Points" text below the life points
var lifePointsText = new Text2('Life Points', {
size: 80,
fill: 0x0000FF,
fontWeight: "bold",
fontFamily: "'Comic Sans MS', cursive, sans-serif"
});
lifePointsText.anchor.set(0.5, 0);
lifePointsText.x = 1024;
lifePointsText.y = 2426; // Position below the hearts
game.addChild(lifePointsText);
LK.gui.bottomLeft.addChild(pauseButton);
// Event listeners for buttons
pauseButton.down = function () {
isPaused = !isPaused;
pauseButton.setText(isPaused ? 'Normal speed' : 'Slowmotion');
};
}
// Reset game state
function resetGame() {
score = 0;
moles.forEach(function (mole) {
return mole.hide();
});
}
// Show the starting menu
function showMenu() {
// Implement menu display logic
}
// Game update loop
game.update = function () {
// Add stars at specific score milestones
if (score === 100 || score === 200 || score === 300 || score === 400 || score === 500) {
var star = new Star();
star.x = Math.random() * 2048;
star.y = 0;
game.addChild(star);
}
if (isPaused) {
return;
}
moles.forEach(function (mole) {
mole.update();
if (!mole.visible && Math.random() < 0.01) {
mole.show();
}
});
game.children.forEach(function (child) {
if (child instanceof Star) {
child.update();
if (!child.visible && Math.random() < 0.01) {
child.show();
}
}
});
};
// Initialize the game
initBoard();
initInterface();
showMenu(); ===================================================================
--- original.js
+++ change.js
@@ -190,8 +190,15 @@
// Implement menu display logic
}
// Game update loop
game.update = function () {
+ // Add stars at specific score milestones
+ if (score === 100 || score === 200 || score === 300 || score === 400 || score === 500) {
+ var star = new Star();
+ star.x = Math.random() * 2048;
+ star.y = 0;
+ game.addChild(star);
+ }
if (isPaused) {
return;
}
moles.forEach(function (mole) {
@@ -205,14 +212,8 @@
child.update();
if (!child.visible && Math.random() < 0.01) {
child.show();
}
- if (score % 100 == 0 && score != 0) {
- var newStar = new Star();
- newStar.x = Math.random() * 2048;
- newStar.y = 0;
- game.addChild(newStar);
- }
}
});
};
// Initialize the game