Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
add a little label "Score" above the scoreTxt
Code edit (1 edits merged)
Please save this source code
User prompt
in animateTimer make size bump
User prompt
in animateTimer make size increase then decrease each sec
User prompt
in handleTimer , when time is under 5, animate timerTxt width and height
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: timerInterval is not defined' in or related to this line: 'LK.clearInterval(timerInterval); // Stop the timer when it reaches 0' Line Number: 321
Code edit (2 edits merged)
Please save this source code
User prompt
in handleTimer , when timer is < 5,, change text fill to red
Code edit (2 edits merged)
Please save this source code
User prompt
change time counter to red in the 5 last seconds
Code edit (5 edits merged)
Please save this source code
User prompt
don't start a shoot if both speed are under 10
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
popupBucket, while fading out, make the bucketAsset rotate
Code edit (4 edits merged)
Please save this source code
User prompt
call popupBucket on score
Code edit (1 edits merged)
Please save this source code
User prompt
in popupMultiplier, add an offset to the asset position so that it doesn't go out of screen
Code edit (5 edits merged)
Please save this source code
User prompt
in popupMultiplier, when grow anim ends fade the asset and destroy it
===================================================================
--- original.js
+++ change.js
@@ -255,16 +255,20 @@
game.addChild(background);
// Score UI
scoreTxt = new Text2(score.toString(), {
size: 150,
- fill: "#006400" // Changed color to dark green
+ fill: "#006400",
+ weight: 1000,
+ dropShadow: true
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Timer UI
timerTxt = new Text2(timerSeconds.toString(), {
size: 150,
- fill: "#006400"
+ fill: "#006400",
+ weight: 1000,
+ dropShadow: true
});
timerTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(timerTxt);
// Update the timer every second
@@ -342,12 +346,12 @@
function handleScore() {
if (isHandlingScore) {
return;
}
- console.log("handleScore...bounceMultiplier=", bounceMultiplier);
+ console.log("handleScore...bounceMultiplier=", bounceMultiplier, "*", currentShootBuckets);
isHandlingScore = true;
currentShootBuckets++;
- score += bounceMultiplier * currentShootBuckets; // Add bounce counter to score
+ score += bounceMultiplier + bounceMultiplier * (currentShootBuckets - 1); // Add bounce counter to score
scoreTxt.setText(score.toString());
popupBucket(currentShootBuckets > 1);
//ball.reset();
ballPassedAboveHoop = false; // Reset the condition after scoring
@@ -369,9 +373,9 @@
function moveHoop() {
//console.log("moveHoop...");
// Initiate gradual movement of the hoop to a new random position within the game boundaries
var targetX = Math.random() * (game.width - hoop.width) + hoop.width / 2;
- var targetY = Math.max(Math.random() * (game.height / 2) + 100, 780); // Ensure hoop's Y position does not go below 780
+ var targetY = game.height * 0.25 + Math.random() * game.height * 0.40; //Math.max(Math.random() * (game.height / 2) + 100, 780);
var moveHoopInterval = LK.setInterval(function () {
hoop.x += (targetX - hoop.x) * 0.05; // Move 5% of the distance per tick
hoop.y += (targetY - hoop.y) * 0.05; // Move 5% of the distance per tick
// Check if the hoop is close enough to the target position to stop
@@ -426,8 +430,9 @@
}
function popupBucket(isCombo) {
console.log("popupBucket", isCombo);
var popupSpeed = 60;
+ var popupMaxSize = isCombo ? 4096 : 2048;
var assetName = isCombo ? 'superCombo' : 'bucket';
var bucketAsset = LK.getAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5,
@@ -442,9 +447,9 @@
var growInterval = LK.setInterval(function () {
bucketAsset.width += popupSpeed;
bucketAsset.height += popupSpeed;
// Check if the asset has grown to or beyond 1024x1024
- if (bucketAsset.width >= 2048 || bucketAsset.height >= 2048) {
+ if (bucketAsset.width >= popupMaxSize || bucketAsset.height >= popupMaxSize) {
LK.clearInterval(growInterval); // Stop the growth animation
LK.setTimeout(function () {
// Start fade out animation
var fadeOutInterval = LK.setInterval(function () {
@@ -466,26 +471,43 @@
if (!isGameRunning) {
return;
}
ball.update();
- if (!hoop.hoopBorderLeft.isHandling && ball.intersects(hoop.hoopBorderLeft)) {
- handleHoopBorder(hoop.hoopBorderLeft);
+ if (ball.intersects(hoop.hoopBorderLeft)) {
+ if (!hoop.hoopBorderLeft.isHandling) {
+ handleHoopBorder(hoop.hoopBorderLeft);
+ }
+ } else {
+ hoop.hoopBorderLeft.isHandling = false;
}
- if (!hoop.hoopBorderRight.isHandling && ball.intersects(hoop.hoopBorderRight)) {
- handleHoopBorder(hoop.hoopBorderRight);
+ if (ball.intersects(hoop.hoopBorderRight)) {
+ if (!hoop.hoopBorderRight.isHandling) {
+ handleHoopBorder(hoop.hoopBorderRight);
+ }
+ } else {
+ hoop.hoopBorderRight.isHandling = false;
}
- if (!hoop.hoopTopTrigger.isHandling && ball.intersects(hoop.hoopTopTrigger)) {
- handleTopTrigger();
+ if (ball.intersects(hoop.hoopTopTrigger)) {
+ if (!hoop.hoopTopTrigger.isHandling) {
+ handleTopTrigger();
+ }
+ } else {
+ hoop.hoopTopTrigger.isHandling = false;
}
- if (!hoop.hoopBottomTrigger.isHandling && ball.intersects(hoop.hoopBottomTrigger)) {
- handleBottomTrigger();
+ if (ball.intersects(hoop.hoopBottomTrigger)) {
+ if (!hoop.hoopBottomTrigger.isHandling) {
+ handleBottomTrigger();
+ }
+ } else {
+ hoop.hoopBottomTrigger.isHandling = false;
}
// Calculate distance between ball and hoop
var distanceX = ball.x - hoop.x;
var distanceY = ball.y - hoop.y;
var distance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
//console.log("Distance between ball and hoop:", distance);
- if (distance > 250) {
+ if (distance > 350) {
+ // ~hoop heigth/2 + ball/heigth/2
isHandlingScore = false;
resetCollisionHandling();
}
//scoreTxt.setText(ball.speedY.toFixed(2));