User prompt
on tap set gamestarted true and hide starttext
User prompt
only spawn balls when gamestarted is true
Code edit (3 edits merged)
Please save this source code
User prompt
remove countdownclock
User prompt
on tap set gamestarted to true
Code edit (1 edits merged)
Please save this source code
User prompt
show text in centre of screen at start: Sort fruits into the right baskets
User prompt
make a boolean gameStarted and set to false at start
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'showText')' in this line: 'LK.gui.overlay.showText('Sort fruits into the right baskets');' Line Number: 259
User prompt
Fix Bug: 'Timeout.tick error: LK.showOverlayText is not a function' in this line: 'LK.showOverlayText('Sort fruits into the right baskets');' Line Number: 259
User prompt
Fix Bug: 'Uncaught TypeError: (intermediate value).set is not a function' in this line: 'LK.gui.center.addChild(new Text2('Sort fruits into the right baskets', {' Line Number: 266
User prompt
pause game at start and show text in center of screen: Sort fruits into the right baskets
Code edit (1 edits merged)
Please save this source code
User prompt
make particle explosions spread more
User prompt
se backgroundgraphics alpha to 0.6
Code edit (1 edits merged)
Please save this source code
User prompt
create an object to hold a background image below everything else on stage
User prompt
scale balls 1.5
User prompt
scale berries 2
User prompt
consider balls' bounding box when checking for edge collisions
User prompt
move blue goal so its bottom edge aligns with bottom of stage
User prompt
move yellow goal so it's right edge aligns with right side of stage
User prompt
move green goal so it's fully visible on stage
Code edit (1 edits merged)
Please save this source code
User prompt
move red goal so it's fully visible on stage
function reflectBall(ball, hitSide) {
if (hitSide === 'left' || hitSide === 'right') {
ball.vx *= -1.5;
} else if (hitSide === 'top' || hitSide === 'bottom') {
ball.vy *= -1.5;
}
}
function determineHitSide(ballBounds, batBounds) {
var dx = ballBounds.x - batBounds.x;
var dy = ballBounds.y - batBounds.y;
if (Math.abs(dx) > Math.abs(dy)) {
return dx < 0 ? 'left' : 'right';
} else {
return dy < 0 ? 'top' : 'bottom';
}
}
var ParticleExplosion = Container.expand(function (color) {
var self = Container.call(this);
self.particles = [];
for (var i = 0; i < 10; i++) {
var particle = self.createAsset('particle_' + color, color + ' Particle Graphics', 0.5, 0.5);
particle.vx = (Math.random() - 0.5) * 10;
particle.vy = (Math.random() - 0.5) * 10;
self.particles.push(particle);
self.addChild(particle);
}
self.update = function () {
for (var i = self.particles.length - 1; i >= 0; i--) {
var p = self.particles[i];
p.x += p.vx;
p.y += p.vy;
p.alpha -= 0.05;
if (p.alpha <= 0) {
p.destroy();
self.particles.splice(i, 1);
}
}
if (self.particles.length === 0) {
self.destroy();
}
};
});
var Score = Container.expand(function () {
var self = Container.call(this);
var scoreValue = 0;
var scoreText = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreText.anchor.set(0.5, 0);
self.addChild(scoreText);
self.x = 2048 - scoreText.width / 2 - 20;
self.y = 20;
self.increaseScore = function (points) {
scoreValue += points;
scoreText.setText(scoreValue.toString());
};
});
var ColoredBall = Container.expand(function (color) {
var self = Container.call(this);
self.lastHitTime = 0;
self.color = color;
var ballGraphics = self.createAsset('ball_' + color, color + ' Ball Graphics', .5, .5);
self.speed = 15;
var angle = Math.random() * 360;
angle += angle % 90 < 7 ? 7 : 0;
self.vx = self.speed * Math.cos(angle * Math.PI / 180);
self.vy = self.speed * Math.sin(angle * Math.PI / 180);
self.move = function () {
self.x += self.vx;
self.y += self.vy;
if (self.x <= 0 || self.x >= 2048) self.vx *= -1;
if (self.y <= 0 || self.y >= 2732) self.vy *= -1;
self.vx += (self.vx > 0 ? -0.1 : 0.1) * (Math.abs(self.vx) > self.speed ? 1 : 0);
self.vy += (self.vy > 0 ? -0.1 : 0.1) * (Math.abs(self.vy) > self.speed ? 1 : 0);
};
self.reset = function () {};
});
var Bat = Container.expand(function () {
var self = Container.call(this);
var batGraphics = self.createAsset('bat', 'Bat Graphics', .5, .5);
batGraphics.scale.set(2);
self.move = function () {};
});
var RedGoal = Container.expand(function () {
var self = Container.call(this);
var goalGraphics = self.createAsset('goal_red', 'Red Goal Graphics', .5, .5);
self.checkScore = function (ball, score) {
if (this.intersects(ball)) {
if (ball.color === 'red') {
score.increaseScore(1);
var explosion = new ParticleExplosion('red');
explosion.x = ball.x;
explosion.y = ball.y;
self.parent.addChild(explosion);
ball.destroy();
self.parent.balls.splice(self.parent.balls.indexOf(ball), 1);
} else {
ball.destroy();
self.parent.balls.splice(self.parent.balls.indexOf(ball), 1);
}
}
};
});
var BlueGoal = Container.expand(function () {
var self = Container.call(this);
var goalGraphics = self.createAsset('goal_blue', 'Blue Goal Graphics', .5, .5);
self.checkScore = function (ball, score) {
if (this.intersects(ball)) {
if (ball.color === 'blue') {
score.increaseScore(1);
var explosion = new ParticleExplosion('blue');
explosion.x = ball.x;
explosion.y = ball.y;
self.parent.addChild(explosion);
ball.destroy();
self.parent.balls.splice(self.parent.balls.indexOf(ball), 1);
} else {
ball.destroy();
self.parent.balls.splice(self.parent.balls.indexOf(ball), 1);
}
}
};
});
var GreenGoal = Container.expand(function () {
var self = Container.call(this);
var goalGraphics = self.createAsset('goal_green', 'Green Goal Graphics', .5, .5);
self.checkScore = function (ball, score) {
if (this.intersects(ball)) {
if (ball.color === 'green') {
score.increaseScore(1);
var explosion = new ParticleExplosion('green');
explosion.x = ball.x;
explosion.y = ball.y;
self.parent.addChild(explosion);
ball.destroy();
self.parent.balls.splice(self.parent.balls.indexOf(ball), 1);
} else {
ball.destroy();
self.parent.balls.splice(self.parent.balls.indexOf(ball), 1);
}
}
};
});
var YellowGoal = Container.expand(function () {
var self = Container.call(this);
var goalGraphics = self.createAsset('goal_yellow', 'Yellow Goal Graphics', .5, .5);
self.checkScore = function (ball, score) {
if (this.intersects(ball)) {
if (ball.color === 'yellow') {
score.increaseScore(1);
var explosion = new ParticleExplosion('yellow');
explosion.x = ball.x;
explosion.y = ball.y;
self.parent.addChild(explosion);
ball.destroy();
self.parent.balls.splice(self.parent.balls.indexOf(ball), 1);
} else {
ball.destroy();
self.parent.balls.splice(self.parent.balls.indexOf(ball), 1);
}
}
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
this.balls = [];
var goals = [];
var bat = null;
function setup() {
var redGoal = self.addChild(new RedGoal());
var redGoal = self.addChild(new RedGoal());
redGoal.x = 2048 / 2 - redGoal.width / 2;
redGoal.y = redGoal.height / 2;
var blueGoal = self.addChild(new BlueGoal());
blueGoal.x = 2048 / 2;
blueGoal.y = 2732 - blueGoal.height;
var greenGoal = self.addChild(new GreenGoal());
greenGoal.x = 0;
greenGoal.y = 2732 / 2;
var yellowGoal = self.addChild(new YellowGoal());
yellowGoal.x = 2048 - yellowGoal.width;
yellowGoal.y = 2732 / 2;
goals.push(redGoal, blueGoal, greenGoal, yellowGoal);
bat = self.addChild(new Bat());
bat.x = 2048 / 2;
bat.y = 2732 - 100;
var colors = ['red', 'blue', 'green', 'yellow'];
LK.setInterval(function () {
if (self.balls.length < 20) {
var colorIndex = Math.floor(Math.random() * colors.length);
var newBall = new ColoredBall(colors[colorIndex]);
newBall.x = 200 + Math.random() * (2048 - 400);
newBall.y = 200 + Math.random() * (2732 - 400);
self.balls.push(newBall);
self.addChild(newBall);
}
}, 2000);
}
function reset() {
for (var i = 0; i < self.balls.length; i++) {
balls[i].reset();
}
}
LK.on('tick', function () {
for (var i = 0; i < self.balls.length; i++) {
self.balls[i].move();
var currentTime = LK.ticks;
if (currentTime - self.balls[i].lastHitTime > 30) {
var ballBounds = self.balls[i];
var batBounds = bat;
if (batBounds.intersects(ballBounds)) {
self.balls[i].lastHitTime = currentTime;
var hitSide = determineHitSide(ballBounds, batBounds);
reflectBall(self.balls[i], hitSide);
}
}
}
for (var i = 0; i < self.balls.length; i++) {
for (var j = 0; j < goals.length; j++) {
goals[j].checkScore(self.balls[i], scoreInstance);
}
}
for (var i = self.children.length - 1; i >= 0; i--) {
if (self.children[i] instanceof ParticleExplosion) {
self.children[i].update();
}
}
});
stage.on('move', function (obj) {
var pos = obj.event.getLocalPosition(self);
bat.x = pos.x;
bat.y = pos.y;
});
var countdownTime = 60;
var countdownClock = new Text2(countdownTime.toString(), {
size: 150,
fill: "#ffffff"
});
countdownClock.anchor.set(0.5, 0);
LK.gui.topCenter.addChild(countdownClock);
var scoreInstance = new Score();
scoreInstance.name = 'scoreInstance';
self.addChild(scoreInstance);
var countdownInterval = LK.setInterval(function () {
countdownTime--;
countdownClock.setText(countdownTime.toString());
if (countdownTime <= 0) {
LK.clearInterval(countdownInterval);
}
}, 1000);
setup();
});
raspberry Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
lemon slice. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
black currant. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
green apple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
yellow plastic tray. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
green plastic tray. topdown view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
blue plastic tray. topdown view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
red plastic tray. topdown view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
top down forest clearing with small bushes.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
lighter color blue.
A little farmer that is comically square shaped.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.