User prompt
The buckets should be reshuffled by the player to allow the player to collect balls
User prompt
Game ends when a ball is not collected
User prompt
RedBall should be collected by RedBucket
User prompt
BlueBall should be collected by BlueBucket
User prompt
GreenBall should be collected by the GreenBucket
User prompt
Add the green ball to the screen to fall down
User prompt
Allow the player to drag the buckets only horizontally
User prompt
Allow the player to drag the buckets
User prompt
Once the player collects ten balls, add the speed of dropping the balls
User prompt
Change the colors of the balls falling to their respective bucket colors and make them round
User prompt
Add click event on the GreenBucket
User prompt
Allow the player to move the GreenBucket to either it's left or right
User prompt
Stop the other balls from falling down and only drop the blue balls
User prompt
Make the blue ball to drop at random intervals and to be captured using the blue bucket
User prompt
Add the RedBucket to the screen
User prompt
Allow the player to move the buckets on the left or right side
User prompt
Add click event on the BlueBucket and allow the player to move the bucket on the canvas
User prompt
Add click event on all the buckets on the screen
User prompt
Allow the player to drag the BlueBucket, GreenBucket and RedBucket to avoid different colors of balls from falling inside
User prompt
Add the red ball onto the screen to fall down and allow the player to collect the red ball using the red bucket
User prompt
Add the BlueBucket onto the canvas
User prompt
Add the buckets to the canvas
User prompt
Allow the player to move the buckets
User prompt
Change the canvas color to turquoise
User prompt
Add the buckets at the bottom of the game canvas
/****
* Classes
****/
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Ball class to represent falling balls
var Ball = Container.expand(function (color) {
var self = Container.call(this);
var ballGraphics = self.attachAsset(color + 'Ball', {
anchorX: 0.5,
anchorY: 0.5
});
self.color = color;
self.speed = 5; // Speed of falling balls
self.update = function () {
self.y += self.speed;
};
});
// Bucket class to represent buckets at the bottom
var Bucket = Container.expand(function (color, xPosition) {
var self = Container.call(this);
var bucketGraphics = self.attachAsset(color + 'Bucket', {
anchorX: 0.5,
anchorY: 0.5
});
self.color = color;
self.x = xPosition;
self.y = 2600; // Position buckets at the bottom
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize arrays and variables
var balls = [];
var buckets = [];
var score = 0;
var scoreTxt = new Text2('0', {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create buckets
buckets.push(game.addChild(new Bucket('BlueBucket', 512)));
buckets.push(game.addChild(new Bucket('GreenBucket', 1024)));
buckets.push(game.addChild(new Bucket('RedBucket', 1536)));
// Function to spawn a new ball
function spawnBall() {
var colors = ['red', 'blue', 'green'];
var color = colors[Math.floor(Math.random() * colors.length)];
var newBall = new Ball(color);
newBall.x = Math.random() * 2048;
newBall.y = 0;
balls.push(newBall);
game.addChild(newBall);
}
// Handle game update
game.update = function () {
for (var i = balls.length - 1; i >= 0; i--) {
balls[i].update();
// Check if ball is in a bucket
for (var j = 0; j < buckets.length; j++) {
if (balls[i].intersects(buckets[j])) {
if (balls[i].color === buckets[j].color) {
score++;
scoreTxt.setText(score);
} else {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
balls[i].destroy();
balls.splice(i, 1);
break;
}
}
// Remove balls that fall off the screen
if (balls[i] && balls[i].y > 2732) {
balls[i].destroy();
balls.splice(i, 1);
}
}
// Spawn a new ball every 60 ticks
if (LK.ticks % 60 === 0) {
spawnBall();
}
};
// Handle touch/mouse events to direct balls
game.down = function (x, y, obj) {
for (var i = 0; i < balls.length; i++) {
if (balls[i].intersects({
x: x,
y: y,
width: 1,
height: 1
})) {
balls[i].x = x;
balls[i].y = y;
}
}
};
game.move = function (x, y, obj) {
for (var i = 0; i < balls.length; i++) {
if (balls[i].intersects({
x: x,
y: y,
width: 1,
height: 1
})) {
balls[i].x = x;
balls[i].y = y;
}
}
};
game.up = function (x, y, obj) {
// No specific action needed on release
};
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.