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
@@ -110,10 +110,10 @@
/****
* Game Code
****/
-// Initialize an array to keep track of all balls
// Define ball assets with increasing sizes and colors for each upgrade level
+// Initialize an array to keep track of all balls
function calculateNextBallType(ballCount) {
var ballType = '1';
if (ballCount > 50) {
var rand = Math.random();
@@ -217,22 +217,24 @@
balls[i].velocity.x = -Math.abs(balls[i].velocity.x);
}
balls[i].velocity.x *= 0.95; // Apply roll resistance
balls[i].x += balls[i].velocity.x;
- // Adjusted collision response to make smaller balls more likely to be pushed to the top
+ // Adjusted collision response to prevent constant movement and clipping
for (var j = 0; j < balls.length; j++) {
if (i != j && balls[i].intersects(balls[j])) {
var dx = balls[j].x - balls[i].x;
var dy = balls[j].y - balls[i].y;
var distance = Math.sqrt(dx * dx + dy * dy);
var overlap = balls[i].width / 2 + balls[j].width / 2 - distance;
- var angle = Math.atan2(dy, dx);
- var separation = overlap > 0 ? overlap : 0; // Full overlap separation
- var massRatio = balls[j].width / balls[i].width;
- balls[i].x -= separation * Math.cos(angle) * massRatio;
- balls[i].y -= separation * Math.sin(angle) * massRatio;
- balls[j].x += separation * Math.cos(angle) / massRatio;
- balls[j].y += separation * Math.sin(angle) / massRatio;
+ if (overlap > 0) {
+ var angle = Math.atan2(dy, dx);
+ // Apply a small force to separate the balls
+ var separationForce = 0.1 * overlap;
+ balls[i].velocity.x -= separationForce * Math.cos(angle);
+ balls[i].velocity.y -= separationForce * Math.sin(angle);
+ balls[j].velocity.x += separationForce * Math.cos(angle);
+ balls[j].velocity.y += separationForce * Math.sin(angle);
+ }
}
}
}
checkCollisions();