Code edit (3 edits merged)
Please save this source code
User prompt
make it so a new bomb does not spawn within 100 pixels of the current position of the ball.
User prompt
on gameover, show the final score on the top of the screen
Code edit (5 edits merged)
Please save this source code
User prompt
add the text "Score: " to the score displayed and "Clicks left: " to the clicks displayed.
Code edit (2 edits merged)
Please save this source code
User prompt
create a variable to store the number of click the player has left. start with 10 clicks. each brick destroyed should add 5 clicks. show the number of clicks left on the top right of the screen. after the number reaches zero or below, the player should not be able to click and bounce the ball.
User prompt
create a separate object for explosion. spawn the new object at the bomb location when it explodes and is destroyed. the explosion object should also be destroyed 0.5 seconds after being spawned.
Code edit (1 edits merged)
Please save this source code
User prompt
add an explosion sprite that scales from 0.2 to 1.0 over 0.5 seconds where the bomb explodes.
User prompt
make it so the bricks and bomb spawn within the screen borders with a padding of 100 pixels
User prompt
when the score is 4000 or above, also start randomly spawning bombs. the bombs should explode after 3 seconds. if the ball touches a bomb it should also blow up and trigger gameOver.
User prompt
when the score is 4000 or above, also start randomly spawning small lava blocks just like the bricks are spawned
User prompt
display the score at the top left of the screen
User prompt
add a scoring variable. add 100 for every brick destroyed. when the gameover is triggered, display the final scroe.
User prompt
dont trigger gameover when the ball touches or exits the top of the screen
User prompt
don't allow the ball to exit the top of the screen.
User prompt
make it so that if the ball touches the top of the screen, it will bounce just like when it touches the side of the screen
User prompt
make the ball from the top of the screen also
User prompt
when all the bricks are destroyed, start spawning bricks every 3 to 5 seconds at random location on the top half of the screen. don't spawn more bricks if there are 10 or more bricks on the screen.
User prompt
add a start button to the game.
User prompt
let the lava blocks overlap by 5%
User prompt
tile the lava block horizontally on the bottom of the screen
Code edit (1 edits merged)
Please save this source code
User prompt
spread the bricks evenly across the screen
/**** * Classes ****/ var Explosion = Container.expand(function () { var self = Container.call(this); var explosionGraphics = self.attachAsset('explosion', { anchorX: 0.5, anchorY: 0.5 }); // Set a timer to destroy the explosion after 0.5 seconds self.timer = LK.setTimeout(function () { self.destroy(); }, 500); }); var Ball = Container.expand(function () { var self = Container.call(this); var ballGraphics = self.attachAsset('ball', { anchorX: 0.5, anchorY: 0.5 }); self.velocityY = -15; self.firstBounce = true; self.bounce = function () { self.velocityY = -15; if (self.firstBounce) { self.velocityX = 5; // slight horizontal velocity self.firstBounce = false; } }; self.velocityX = 0; self.move = function () { self.x += self.velocityX; self.y += self.velocityY; self.velocityY += 0.5; // gravity effect // Check for ball and bomb collision for (var i = game.children.length - 1; i >= 0; i--) { var obj = game.children[i]; if (obj instanceof Bomb && self.intersects(obj)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(scoreDisplay.updateScore(score)); return; } } // Check for side boundaries and make the ball bounce if (self.x < 0 || self.x > 2048) { self.velocityX *= -1; // Invert the horizontal velocity } }; }); var Bomb = Container.expand(function () { var self = Container.call(this); var bombGraphics = self.attachAsset('bomb', { anchorX: 0.5, anchorY: 0.5 }); self.timer = LK.setTimeout(function () { self.explode(); }, 3000); self.explode = function () { if (self.parent) { var explosion = game.addChild(new Explosion()); explosion.x = self.x; explosion.y = self.y; self.destroy(); } }; }); var Brick = Container.expand(function () { var self = Container.call(this); var brickGraphics = self.attachAsset('brick', { anchorX: 0.5, anchorY: 0.5 }); }); var StartButton = Container.expand(function () { var self = Container.call(this); var startButtonGraphics = self.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); self.on('down', function () { game.start(); }); }); var Lava = Container.expand(function () { var self = Container.call(this); var lavaGraphics = self.attachAsset('lava', { anchorX: 0.5, anchorY: 0 }); self.y = 2800 - self.height; // position at the bottom of the screen }); var ScoreDisplay = Container.expand(function () { var self = Container.call(this); var scoreText = new Text2('Score: 0', { size: 80, fill: "#ffffff" }); scoreText.anchor.set(0, 0.5); self.addChild(scoreText); self.updateScore = function (newScore) { scoreText.setText('Score: ' + newScore.toString()); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ var gameStarted = false; var score = 0; var clicksLeft = 10; var ball = game.addChild(new Ball()); ball.x = 2048 / 2; ball.y = 2732 / 2; var lavaTiles = []; var numberOfLavaTiles = Math.ceil(2048 / 400); // Calculate the number of lava tiles needed to cover the screen width for (var i = 0; i < numberOfLavaTiles; i++) { var lava = game.addChild(new Lava()); lava.x = i * 400 * 0.95 + 200; // Position each tile with a 5% overlap lavaTiles.push(lava); } var scoreDisplay = game.addChild(new ScoreDisplay()); scoreDisplay.x = 80; // Position score display 50 pixels from the left scoreDisplay.y = 80; // Position score display 50 pixels from the top // Create and display clicks left text var clicksDisplay = new Text2('Clicks left: ' + clicksLeft.toString(), { size: 60, fill: "#ffffff" }); clicksDisplay.anchor.set(1, 0); // Anchor to the top right LK.gui.topRight.addChild(clicksDisplay); var bricks = []; var brickRowCount = 4; var brickColumnCount = 5; var brickPadding = 10; var brickOffsetTop = 200; var brickOffsetLeft = (2048 - brickColumnCount * (120 + brickPadding)) / 2; for (var i = 0; i < brickRowCount; i++) { for (var j = 0; j < brickColumnCount; j++) { var brick = game.addChild(new Brick()); brick.x = brickOffsetLeft + j * (120 + brickPadding); brick.y = brickOffsetTop + i * (103.67 + brickPadding); bricks.push(brick); } } var startButton = game.addChild(new StartButton()); startButton.x = 2048 / 2; startButton.y = 2732 / 2; game.start = function () { gameStarted = true; startButton.destroy(); }; game.on('down', function (obj) { if (clicksLeft > 0) { ball.bounce(); clicksLeft--; clicksDisplay.setText('Clicks left: ' + clicksLeft.toString()); } }); LK.on('tick', function () { if (gameStarted) { ball.move(); } // Check collision with bricks and make the ball bounce for (var i = bricks.length - 1; i >= 0; i--) { if (ball.intersects(bricks[i])) { bricks[i].destroy(); bricks.splice(i, 1); ball.velocityY *= -1; // Invert the velocity to make the ball bounce score += 100; scoreDisplay.updateScore(score); clicksLeft += 3; clicksDisplay.setText('Clicks left: ' + clicksLeft.toString()); } } // Check collision with lava if (ball.intersects(lava) || ball.y > 2732) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } // Spawn bricks and bombs at random locations on the top half of the screen if (bricks.length === 0 || bricks.length < 10 && LK.ticks % (180 + Math.floor(Math.random() * 121)) === 0) { if (score >= 4000) { var bomb; do { bomb = new Bomb(); bomb.x = 100 + Math.random() * (2048 - 200); bomb.y = 100 + Math.random() * (2732 / 2 - 200); } while (Math.abs(bomb.x - ball.x) < 100 && Math.abs(bomb.y - ball.y) < 100); game.addChild(bomb); } var newBrick = game.addChild(new Brick()); newBrick.x = 100 + Math.random() * (2048 - 200); newBrick.y = 100 + Math.random() * (2732 / 2 - 200); bricks.push(newBrick); } });
===================================================================
--- original.js
+++ change.js
@@ -136,10 +136,10 @@
});
clicksDisplay.anchor.set(1, 0); // Anchor to the top right
LK.gui.topRight.addChild(clicksDisplay);
var bricks = [];
-var brickRowCount = 5;
-var brickColumnCount = 8;
+var brickRowCount = 4;
+var brickColumnCount = 5;
var brickPadding = 10;
var brickOffsetTop = 200;
var brickOffsetLeft = (2048 - brickColumnCount * (120 + brickPadding)) / 2;
for (var i = 0; i < brickRowCount; i++) {
a cartoon red brick. bright. shiny. pixel art. no text.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cartoon bomb. bright. shiny. pixel art. no text. front view. already lit.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A start button. rectangular. text says "start". pixel art style. red and white.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cartoon explosion. pixel art style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a blue shiny ball. pixel art style. no shadows.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a shiny silver brick.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a shiny gold brick.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cartoon explosion made of red bricks. no shadows.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.