User prompt
Change la couleur du score en noir
Code edit (2 edits merged)
Please save this source code
User prompt
déplace le code qui gÚre le fait de marquer un panier dans une fonction globale
User prompt
Quand un palier est marqué, laisse un délai avant de réinitialiser et de bouger le palier.
Code edit (3 edits merged)
Please save this source code
User prompt
La balle doit arrĂȘter de tourner lorsque la vitesse X ou Y est Ă zĂ©ro.
Code edit (5 edits merged)
Please save this source code
User prompt
dans game.on('up' limite la vitesse Ă maxSpeed
Code edit (1 edits merged)
Please save this source code
User prompt
ajoute une vitesse maximale
Code edit (3 edits merged)
Please save this source code
User prompt
quand le ballon passe sous le panier (+ sa hauteur), mettre ballPassedAboveHoop = faux
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
met ballPassedAboveHoop Ă vrai lorsque le ballon passe au dessus du panier
Code edit (3 edits merged)
Please save this source code
User prompt
On ne doit marquer des points que si on passe par au-dessus du panier.
User prompt
Quand le ballon arrive par en dessous du panier, il doit rebondir.
User prompt
Pour marquer, il faut que le ballon soit d'abord passé au-dessus du panier.
User prompt
Ajoute une variable globale qui indique que le ballon est passé au-dessus du panier.
User prompt
RĂ©initialise le ballon lorsque sa vitesse est trĂšs faible.
User prompt
RĂ©initialise le ballon lorsque sa vitesse est faible.
User prompt
Retire le Game Over
User prompt
Le ballon doit tourner sur lui-mĂȘme lorsqu'il est lancĂ©.
User prompt
Le Y du palier ne doit pas passer en dessous de 500.
===================================================================
--- original.js
+++ change.js
@@ -53,9 +53,10 @@
}
// Allow the ball to fall off the bottom without reversing speed or losing points
// If the ball touches the bottom boundary and score is 0, trigger game over
// Check if the ball is coming from below the hoop and make it bounce
- if (self.y >= game.height || self.intersects(hoop) && self.speedY > 0) {
+ if (self.y >= game.height) {
+ // || self.intersects(hoop) && self.speedY > 0) {
self.speedY *= -1;
}
}
};
@@ -161,32 +162,36 @@
});
LK.on('tick', function () {
ball.update();
// Check for scoring
- if (ballPassedAboveHoop && ball.intersects(hoop)) {
- score += 1;
- scoreTxt.setText(score.toString());
- ball.reset();
- ballPassedAboveHoop = false; // Reset the condition after scoring
- // Create and add confetti effect to the game
- var confetti = game.addChild(new Confetti());
- confetti.x = 0; // Position confetti at the hoop's position
- confetti.y = 0;
- LK.on('tick', function () {
- confetti.animate(); // Animate confetti
- });
- // 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, 500); // Ensure hoop's Y position does not go below 500
- 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
- if (Math.abs(hoop.x - targetX) < 1 && Math.abs(hoop.y - targetY) < 1) {
- hoop.setPosition(targetX, targetY); // Ensure hoop is exactly at target position
- LK.clearInterval(moveHoopInterval); // Stop the interval
- }
- }, 16); // Run every 16ms (~60FPS)
+ if (ball.intersects(hoop)) {
+ if (ballPassedAboveHoop) {
+ score += 1;
+ scoreTxt.setText(score.toString());
+ ball.reset();
+ ballPassedAboveHoop = false; // Reset the condition after scoring
+ // Create and add confetti effect to the game
+ var confetti = game.addChild(new Confetti());
+ confetti.x = 0; // Position confetti at the hoop's position
+ confetti.y = 0;
+ LK.on('tick', function () {
+ confetti.animate(); // Animate confetti
+ });
+ // 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, 500); // Ensure hoop's Y position does not go below 500
+ 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
+ if (Math.abs(hoop.x - targetX) < 1 && Math.abs(hoop.y - targetY) < 1) {
+ hoop.setPosition(targetX, targetY); // Ensure hoop is exactly at target position
+ LK.clearInterval(moveHoopInterval); // Stop the interval
+ }
+ }, 16); // Run every 16ms (~60FPS)
+ } else if (ball.speedY > 0) {
+ ball.speedY *= -1;
+ }
}
// Reset ball if it goes off-screen
if (ball.y > game.height + 50 || ball.x < -50 || ball.x > game.width + 50) {
ball.reset();