User prompt
when a lot off balls are spawned in they start to constantly move and clip into eachother. add something to fix it
User prompt
a smaller ball should always be more likely to be pushed to the top
User prompt
make the balls in the ball display all 100by 100
User prompt
add a 1 seconds delay to balls spawning
User prompt
calculate the next ball directly after the previous mouse click
User prompt
display the nextball visailly
User prompt
already calculate what balls is going to drop before mouseclikc and display that
User prompt
add a place in the top left that shows the next ball type wich will be spawned
User prompt
only reset the multiplier save the score
User prompt
if no balls merge for 4 seconds reset the multiplier
User prompt
show the multiplier in the top left
User prompt
make a multiplier
User prompt
save the score when the multiplier resets so the score doesnt reset
User prompt
make the multiplier work
User prompt
make the blinking last 1 seconds unless the multiplier gets increased
User prompt
stop the blinking after the multiplier resets
User prompt
make the multiplier last 3 seconds and start blinking at 1 seconds left
User prompt
stop the multiplier from blinking when it is reset
User prompt
make the multiplier last 3 seconds and start blinking at 1 seconds left
User prompt
make the multiplier last 2 seconds, make an indicator for it that blinks
User prompt
apply the multiplier to the score and save it
User prompt
dont reset the score when the multiplier resets
User prompt
dont reset the score on multiplier reset
User prompt
make the score multiplier work
User prompt
add a multiplier if balls merge that lasts a few seconds and make an indicator for it in the top left
===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,19 @@
/****
* Classes
****/
+// Class to display the next ball type in the top left corner
+var NextBallDisplay = Container.expand(function () {
+ var self = Container.call(this);
+ var nextBallText = new Text2('Next Ball: Type 1', {
+ size: 50,
+ fill: "#ffffff"
+ });
+ self.addChild(nextBallText);
+ self.updateNextBallType = function (type) {
+ nextBallText.setText('Next Ball: Type ' + type);
+ };
+});
var Score = Container.expand(function () {
var self = Container.call(this);
var scoreText = new Text2('0', {
size: 150,
@@ -10,27 +22,13 @@
self.addChild(scoreText);
self.value = 0;
self.updateScore = function () {
self.value = balls.reduce(function (score, ball) {
- return score + Math.pow(2, parseBallType(ball.type) - 1) * game.multiplier.value;
+ return score + Math.pow(2, parseBallType(ball.type) - 1);
}, 0);
scoreText.setText(self.value.toString());
};
});
-// Multiplier class to represent score multipliers
-var Multiplier = Container.expand(function () {
- var self = Container.call(this);
- var multiplierText = new Text2('x1', {
- size: 100,
- fill: "#ffffff"
- });
- self.addChild(multiplierText);
- self.value = 1;
- self.updateMultiplier = function (newMultiplier) {
- self.value = newMultiplier;
- multiplierText.setText('x' + self.value.toString());
- };
-});
// Ball class to represent the game balls
var Ball = Container.expand(function (type) {
var self = Container.call(this);
var assetId = 'ball' + type;
@@ -97,26 +95,22 @@
* Game Code
****/
// Initialize an array to keep track of all balls
// Define ball assets with increasing sizes and colors for each upgrade level
+var nextBallDisplay = new NextBallDisplay();
+LK.gui.topLeft.addChild(nextBallDisplay);
function parseBallType(type) {
return Number(type);
}
var score = new Score();
-var multiplier = new Multiplier();
-var lastMergeTime = Date.now();
LK.gui.top.addChild(score);
-LK.gui.topLeft.addChild(multiplier);
-game.multiplier = multiplier;
var balls = [];
// Function to check for collisions and upgrade balls
function checkCollisions() {
for (var i = 0; i < balls.length; i++) {
for (var j = i + 1; j < balls.length; j++) {
if (balls[i].intersects(balls[j]) && balls[i].type === balls[j].type) {
balls[i].upgrade();
- game.multiplier.updateMultiplier(game.multiplier.value + 1);
- lastMergeTime = Date.now();
balls[j].destroy();
balls.splice(j, 1);
// Adjust index to continue checking without skipping a ball
j--;
@@ -165,8 +159,10 @@
}
var newBall = new Ball(ballType);
newBall.x = pos.x + (Math.random() * 20 - 10);
newBall.y = 300 + (Math.random() * 20 - 10);
+ // Update the next ball type display
+ nextBallDisplay.updateNextBallType(ballType);
balls.push(newBall);
game.addChild(newBall);
ballCount++;
console.log('Ball count: ' + ballCount + ', Ball types: ' + ballTypesToString(balls));
@@ -176,12 +172,9 @@
}
});
// Main game update loop
LK.on('tick', function () {
- if (Date.now() - lastMergeTime > 4000 && game.multiplier.value > 1) {
- game.multiplier.updateMultiplier(1);
- lastMergeTime = Date.now(); // Reset the last merge time to prevent constant resetting
- }
+ score.updateScore();
// Apply gravity to each ball
for (var i = 0; i < balls.length; i++) {
balls[i].velocity.y += 0.5; // Increased gravity acceleration
if (balls[i].y + balls[i].velocity.y > 2732 - balls[i].height / 2) {