Code edit (9 edits merged)
Please save this source code
User prompt
implement swipeAnim, bt adding the swipe asset and make it move infinetly from ball to the center of the screen
Code edit (1 edits merged)
Please save this source code
User prompt
implement animateScore with wdith and height grow and restore of scoreTxt
Code edit (7 edits merged)
Please save this source code
User prompt
animate scoreTxt when player scores
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- original.js
+++ change.js
@@ -207,8 +207,9 @@
/* ********************************************************************************* */
var isGameRunning = false;
var isHandlingScore = false;
var bounceMultiplier = 1;
+var currentShootBuckets = 0;
var maxSpeed = 100;
var ballPassedAboveHoop = false;
var ballPassedInsideHoop = false;
var timerSeconds = 60; // Set the initial timer value in seconds
@@ -234,8 +235,9 @@
var endPosition = obj.event.getLocalPosition(game);
var speedX = Math.max(Math.min((endPosition.x - startPosition.x) * 0.1, maxSpeed), -maxSpeed);
var speedY = Math.max(Math.min((endPosition.y - startPosition.y) * 0.1, maxSpeed), -maxSpeed);
console.log("============================= SHOOT ===========================");
+ currentShootBuckets = 0;
ball.launch(speedX, speedY);
startPosition = null;
}
});
@@ -340,13 +342,14 @@
function handleScore() {
if (isHandlingScore) {
return;
}
- console.log("handleScore...");
+ console.log("handleScore...bounceMultiplier=", bounceMultiplier);
isHandlingScore = true;
- score += bounceMultiplier; // Add bounce counter to score
+ currentShootBuckets++;
+ score += bounceMultiplier * currentShootBuckets; // Add bounce counter to score
scoreTxt.setText(score.toString());
- popupBucket(true);
+ popupBucket(currentShootBuckets > 1);
//ball.reset();
ballPassedAboveHoop = false; // Reset the condition after scoring
ballPassedInsideHoop = false;
// Create and add confetti effect to the game
@@ -381,9 +384,9 @@
}
}, 16); // Run every 16ms (~60FPS)
}
function popupMultiplier(value, x, y) {
- console.log("popupMultiplier()...", value, x, y);
+ //console.log("popupMultiplier()...", value, x, y);
// popup the asset corresponding to the value
if (value < 2) {
return;
}
@@ -423,15 +426,17 @@
}
function popupBucket(isCombo) {
console.log("popupBucket", isCombo);
var popupSpeed = 60;
- var bucketAsset = LK.getAsset('bucket', {
+ var assetName = isCombo ? 'superCombo' : 'bucket';
+ var bucketAsset = LK.getAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5,
x: game.width / 2,
- y: game.height / 2,
+ y: game.height * 0.75,
width: 1,
- height: 1
+ height: 1,
+ alpha: 0.8
});
game.addChild(bucketAsset);
// Animate the growth of the x2 asset to 1024x1024
var growInterval = LK.setInterval(function () {
@@ -443,15 +448,15 @@
LK.setTimeout(function () {
// Start fade out animation
var fadeOutInterval = LK.setInterval(function () {
bucketAsset.alpha -= 0.025; // Reduce alpha to fade out
- bucketAsset.rotation += 0.1; // Rotate the bucketAsset
+ bucketAsset.rotation += 0.2; // Rotate the bucketAsset
if (bucketAsset.alpha <= 0) {
LK.clearInterval(fadeOutInterval); // Stop the fade out animation
bucketAsset.destroy(); // Destroy the asset after fading out
}
}, 4); // Run every 16ms (~60FPS)
- }, 300);
+ }, 200);
}
}, 1); // Run every 16ms (~60FPS)
}
/* ********************************************************************************* */
@@ -479,8 +484,9 @@
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) {
+ isHandlingScore = false;
resetCollisionHandling();
}
//scoreTxt.setText(ball.speedY.toFixed(2));
});