User prompt
Write is small font, list, on the screen: Red, Blue, Green, Blue, Red
User prompt
When level 2 starts
User prompt
Write Level 2 at the topmost left part of the screen
User prompt
Instead of ending, write on the screen "Level 2"
User prompt
Play a sound effect to signify achievement
User prompt
Stop imagining
User prompt
Stop rotating buckets
User prompt
Are you able to implement level two using the same assets
User prompt
Don't increase rotation speed
User prompt
Remove the color changing zone
User prompt
Any other puzzle element that we can add on the game
User prompt
Remove the RedBonusBall
User prompt
Don't start with red. Do it randomly
User prompt
You can add rotating buckets puzzle element.
User prompt
Always start with red
User prompt
Reduce the number of balls falling down so that the player has enough time to collect them
User prompt
Reduce the speed to one
User prompt
Reduce the falling speed to 3
User prompt
Add a simple puzzle element onto the game
User prompt
Remove Bonusblueball
User prompt
Remove GreenBonusBall
User prompt
At the end of level one, write Level 2
User prompt
level two of game starts at 120 seconds. Level 2, increase the balls and speed of dropping them
/**** * Classes ****/ var Ball = Container.expand(function (color) { var self = Container.call(this); self.attachAsset(color + 'Ball', { anchorX: 0.5, anchorY: 0.5 }); self.color = color; self.speed = 4; self.dragging = false; self.dragStartX = 0; self.dragStartY = 0; self.update = function () { if (!self.dragging) { self.y += self.speed; } if (self.x < 40) { self.x = 40; } if (self.x > 2008) { self.x = 2008; } }; self.startDrag = function (x, y) { self.dragging = true; self.dragStartX = x - self.x; self.dragStartY = y - self.y; self.speed = 0; }; self.drag = function (x, y) { if (self.dragging) { self.x = x - self.dragStartX; self.y = y - self.dragStartY; } }; self.stopDrag = function () { self.dragging = false; self.drop(); }; self.drop = function () { self.speed = 7; for (var i = 0; i < buckets.length; i++) { if (buckets[i].intersects(self)) { if ((self.color === 'Red' || self.color === 'RedBonus') && buckets[i].color === 'Red' || (self.color === 'Blue' || self.color === 'BlueBonus') && buckets[i].color === 'Blue' || (self.color === 'Green' || self.color === 'GreenBonus') && buckets[i].color === 'Green') { LK.getSound('Poof').play(); if (self.color.includes('Bonus')) { score += 5; LK.getSound('Yes').play(); // Assuming 'Yes' is the sound ID for the positive sound effect } else { score++; } scoreTxt.setText(score); if (self.color === 'Blue' && buckets[i].color === 'Blue' || self.color === 'Green' && buckets[i].color === 'Green' || self.color === 'Red' && buckets[i].color === 'Red') { self.speed = 0; self.y = buckets[i].y - buckets[i].height / 2 + self.height / 2 + balls.filter(function (ball) { return ball.color === self.color && ball.settled; }).length * self.height; self.settled = true; } else { LK.effects.flashObject(self, 0xffffff, 500); LK.getSound('GameEnd').play(); self.destroy(); balls.splice(balls.indexOf(self), 1); } break; } else { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } } } }; self.intersects = function (obj) { return obj.x >= self.x - self.width / 2 && obj.x <= self.x + self.width / 2 && obj.y >= self.y - self.height / 2 && obj.y <= self.y + self.height / 2; }; return self; }); var RedBonusBall = Ball.expand(function () { var self = Ball.call(this, 'RedBonus'); self.drop = function () { self.speed = 6; for (var i = 0; i < buckets.length; i++) { if (self.intersects(buckets[i])) { if (buckets[i].color === 'Red') { score += 20; LK.getSound('Poof').play(); scoreTxt.setText(score); for (var j = 0; j < balls.length; j++) { if (balls[j].color === 'Red' && balls[j].settled) { balls[j].destroy(); balls.splice(j, 1); j--; } } LK.getSound('GameEnd').play(); LK.effects.flashObject(buckets[i], 0xff0000, 500); // Flash the RedBucket to indicate explosion LK.effects.flashObject(self, 0xffffff, 500); self.destroy(); balls.splice(balls.indexOf(self), 1); break; } } } }; return self; }); // Removed duplicate BonusBlueBall definition var BlueBall = Ball.expand(function () { var self = Ball.call(this, 'Blue'); self.drop = function () { self.speed = 5; for (var i = 0; i < buckets.length; i++) { if (self.intersects(buckets[i])) { if (buckets[i].color === 'Blue') { score += 1; LK.getSound('Poof').play(); scoreTxt.setText(score); self.speed = 0; self.y = buckets[i].y - buckets[i].height / 2 + self.height / 2 + balls.filter(function (ball) { return ball.color === 'Blue' && ball.settled; }).length * self.height; self.settled = true; LK.getSound('GameEnd').play(); break; } else if (buckets[i].color === 'Blue' && self.color === 'BlueBonus') { score += 10; LK.getSound('Poof').play(); scoreTxt.setText(score); self.destroy(); balls.splice(balls.indexOf(self), 1); break; } } } }; return self; }); var BonusBall = Container.expand(function () { var self = Container.call(this); self.update = function () { // Define the update behavior for BonusBall }; return self; }); var Bucket = Container.expand(function (color, xPosition) { var self = Container.call(this); self.attachAsset(color + 'Bucket', { anchorX: 0.5, anchorY: 0.5 }); self.color = color; self.x = xPosition; self.y = 2600; self.intersects = function (obj) { return obj.x >= self.x - self.width / 2 && obj.x <= self.x + self.width / 2 && obj.y >= self.y - self.height / 2 && obj.y <= self.y + self.height / 2; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x40E0D0 // Turquoise background }); /**** * Game Code ****/ // Play cool music in the background at all times LK.playMusic('Cool', { loop: true }); var balls = []; var buckets = []; var score = 0; var scoreBackground = LK.getAsset('scoreBackground', { width: 400, height: 200, color: 0x800000, // Maroon color alpha: 0.5, // Semi-transparent for glass-like effect anchorX: 0.5, anchorY: 0 }); LK.gui.top.addChild(scoreBackground); var scoreTxt = new Text2('0', { size: 150, fill: 0x800000, // Bold maroon color fontWeight: 'bold' // Set font weight to bold }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Add a timer display at the top right var timerTxt = new Text2('0:00', { size: 150, fill: 0xFFFF00, // Glass-like yellow color fontWeight: 'bold', // Set font weight to bold alpha: 0.5 // Semi-transparent for glass-like effect }); timerTxt.anchor.set(1, 0); // Anchor to the top right LK.gui.topRight.addChild(timerTxt); // Update the timer every second var startTime = Date.now(); LK.setInterval(function () { var elapsedTime = Math.floor((Date.now() - startTime) / 1000); var minutes = Math.floor(elapsedTime / 60); var seconds = elapsedTime % 60; timerTxt.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds); // Increase the speed of falling balls by one when the time hits 60 seconds if (elapsedTime === 60) { balls.forEach(function (ball) { ball.speed += 1; }); } // Level 2 starts at 120 seconds if (elapsedTime === 120) { balls.forEach(function (ball) { ball.speed += 2; // Increase speed further for level 2 }); Ball.prototype.speed += 2; // Increase base speed for new balls if (LK.ticks % 20 === 0) { // Increase spawn rate for level 2 spawnBall(); } } }, 1000); var bucketWidth = 350; // Width of the bucket var bucketSpacing = (2048 - 3 * bucketWidth) / 4; // Calculate spacing between buckets buckets.push(game.addChild(new Bucket('Blue', bucketSpacing + bucketWidth / 2, 2600))); buckets.push(game.addChild(new Bucket('Green', 2 * bucketSpacing + 1.5 * bucketWidth, 2600))); buckets.push(game.addChild(new Bucket('Red', 3 * bucketSpacing + 2.5 * bucketWidth, 2600))); function spawnBall() { var colors = ['Red', 'Blue', 'Green']; var newBall; if (Math.random() < 0.1) { // 10% chance to spawn a bonus ball newBall = new BonusBall(); } else { var color = colors[Math.floor(Math.random() * colors.length)]; newBall = new Ball(color); } var bucketPositions = [400, 1024, 1648]; // x-positions of the buckets var randomOffset = (Math.random() - 0.5) * 200; // Random offset to allow some variation newBall.x = bucketPositions[Math.floor(Math.random() * bucketPositions.length)] + randomOffset; newBall.y = 0; balls.push(newBall); game.addChild(newBall); } game.update = function () { for (var i = balls.length - 1; i >= 0; i--) { balls[i].update(); for (var j = 0; j < buckets.length; j++) { if (balls[i].intersects(buckets[j])) { if (balls[i].color === buckets[j].color || balls[i].color === 'RedBonus' && buckets[j].color === 'Red') { score++; scoreTxt.setText(score); if (balls[i].color === 'Blue' && buckets[j].color === 'Blue') { balls[i].speed = 0; balls[i].y = buckets[j].y - buckets[j].height / 2 + balls[i].height / 2; balls[i].settled = true; } else { balls[i].destroy(); balls.splice(i, 1); } break; } else if (buckets[j].color === 'Green' && (balls[i].color === 'Blue' || balls[i].color === 'Red') || buckets[j].color === 'Blue' && (balls[i].color === 'Green' || balls[i].color === 'Red') || buckets[j].color === 'Red' && (balls[i].color === 'Green' || balls[i].color === 'Blue')) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } else { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } } } if (balls[i] && balls[i].y > 2600) { balls[i].destroy(); balls.splice(i, 1); } } Ball.prototype.speed = score >= 30 ? 5 : 2 + Math.floor(LK.ticks / 3600); // Increase speed to 5 after 30 points, otherwise increase by 1 every minute if (score >= 40) { if (LK.ticks % 30 === 0) { // Increase spawn rate after score reaches 40 spawnBall(); } } else { if (LK.ticks % 60 === 0) { spawnBall(); } } var bonusBallExists = balls.some(function (ball) { return ball.color && ball.color.includes('Bonus'); }); if (!bonusBallExists) { if (Math.random() < 0.005) { // 1% chance every tick for RedBonusBall var newRedBonusBall = new RedBonusBall(); newRedBonusBall.x = Math.random() * 2048; newRedBonusBall.y = 0; balls.push(newRedBonusBall); game.addChild(newRedBonusBall); } } }; game.down = function (x, y) { for (var i = 0; i < balls.length; i++) { if (balls[i].intersects({ x: x, y: y })) { balls[i].startDrag(x, y); break; } } }; game.move = function (x, y) { for (var i = 0; i < balls.length; i++) { if (balls[i].dragging) { balls[i].drag(x, y); } } }; game.up = function () { for (var i = 0; i < balls.length; i++) { if (balls[i].dragging) { balls[i].stopDrag(); } } }; // Attach event listeners for dragging game.on('pointerdown', game.down); game.on('pointermove', game.move); game.on('pointerup', game.up);
===================================================================
--- original.js
+++ change.js
@@ -106,37 +106,8 @@
}
};
return self;
});
-var GreenBonusBall = Ball.expand(function () {
- var self = Ball.call(this, 'GreenBonus');
- self.drop = function () {
- self.speed = 6;
- for (var i = 0; i < buckets.length; i++) {
- if (self.intersects(buckets[i])) {
- if (buckets[i].color === 'Green') {
- score += 20;
- LK.getSound('Poof').play();
- scoreTxt.setText(score);
- for (var j = 0; j < balls.length; j++) {
- if (balls[j].color === 'Green' && balls[j].settled) {
- balls[j].destroy();
- balls.splice(j, 1);
- j--;
- }
- }
- LK.getSound('GameEnd').play();
- LK.effects.flashObject(buckets[i], 0xff0000, 500); // Flash the GreenBucket to indicate explosion
- LK.effects.flashObject(self, 0xffffff, 500);
- self.destroy();
- balls.splice(balls.indexOf(self), 1);
- break;
- }
- }
- }
- };
- return self;
-});
// Removed duplicate BonusBlueBall definition
var BlueBall = Ball.expand(function () {
var self = Ball.call(this, 'Blue');
self.drop = function () {
@@ -250,20 +221,8 @@
});
}
// Level 2 starts at 120 seconds
if (elapsedTime === 120) {
- var level2Txt = new Text2('Level 2', {
- size: 200,
- fill: 0xFFFF00,
- // Yellow color
- fontWeight: 'bold',
- alpha: 0.8 // Semi-transparent for effect
- });
- level2Txt.anchor.set(0.5, 0.5); // Center the text
- LK.gui.center.addChild(level2Txt);
- LK.setTimeout(function () {
- LK.gui.center.removeChild(level2Txt);
- }, 2000); // Remove the text after 2 seconds
balls.forEach(function (ball) {
ball.speed += 2; // Increase speed further for level 2
});
Ball.prototype.speed += 2; // Increase base speed for new balls
@@ -343,15 +302,8 @@
return ball.color && ball.color.includes('Bonus');
});
if (!bonusBallExists) {
if (Math.random() < 0.005) {
- // 1% chance every tick for GreenBonusBall
- var newGreenBonusBall = new GreenBonusBall();
- newGreenBonusBall.x = Math.random() * 2048;
- newGreenBonusBall.y = 0;
- balls.push(newGreenBonusBall);
- game.addChild(newGreenBonusBall);
- } else if (Math.random() < 0.005) {
// 1% chance every tick for RedBonusBall
var newRedBonusBall = new RedBonusBall();
newRedBonusBall.x = Math.random() * 2048;
newRedBonusBall.y = 0;
A red ball with the words bonus. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A Green ball written bonus. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Metallic marron clear background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.