User prompt
Randomise intital speed and direction of ball
User prompt
smallballs should bounce off the edge of the screen
User prompt
generate 20 smallball when enemy hits the ball
User prompt
add 5 new balls each time the player hits the ball, they should move towards the other player in an arc at random speeds
User prompt
new balls should be 80% of the size of ball
User prompt
new balls are still static, they should move in random directions
User prompt
the new balls are static, plox fix xxx
User prompt
add 5 new balls at the start of a point, make them fire at random dierections and speeds
User prompt
Delete extra balls added at end of round
User prompt
There is a bug, only one ball should be able to score one point per round
User prompt
Also create 5 balls every time a player contacts the real ball, they should shoot in a 25 degree arc towards the other player
User prompt
No, create 5 new balls at tthe start of ever point
User prompt
Now there is only one ball, or they might all be moving the same path, please change that
User prompt
Only one ball is move, but I'd liek all of them to move
User prompt
Repair change set 13
User prompt
create 5 balls at start of game
User prompt
clone ball 5 times
User prompt
create increasing numbers of balls on every round
User prompt
upon loss, double the number of balls
User prompt
make the rendered blood stay on screen
User prompt
add blood splatter special effects
User prompt
Migrate to the latest version of LK
Remix started
Copy Wall Bounce
===================================================================
--- original.js
+++ change.js
@@ -57,9 +57,8 @@
/****
* Game Code
****/
// Initialize balls and paddles
-var pointScored = false; // Flag to track if a point has been scored in the current round
var balls = [];
for (var i = 0; i < 5; i++) {
var ball = game.addChild(new Ball());
ball.x = 1024; // Center horizontally
@@ -113,19 +112,8 @@
}
// Check for ball collisions with paddles
function checkCollisions() {
if (ball.intersects(playerPaddle)) {
- pointScored = false; // Reset pointScored flag
- // Create 5 new balls in a 25 degree arc towards the AI paddle
- for (var i = -2; i <= 2; i++) {
- var newBall = game.addChild(new Ball());
- newBall.x = ball.x;
- newBall.y = ball.y;
- var angle = i * 25 * (Math.PI / 180); // Convert degrees to radians
- newBall.speedX = Math.cos(angle) * 15;
- newBall.speedY = Math.sin(angle) * 15;
- balls.push(newBall);
- }
// Calculate the difference between the center of the ball and the center of the paddle
var diffY = ball.y - playerPaddle.y;
// Normalize the difference to get a value between -1 and 1
var normalizedDiffY = diffY / (playerPaddle.height / 2);
@@ -137,18 +125,8 @@
ball.speedX = Math.cos(angle) * 5 * 3;
ball.speedY = Math.sin(angle) * 5 * 3;
}
if (ball.intersects(aiPaddle)) {
- // Create 5 new balls in a 25 degree arc towards the player paddle
- for (var i = -2; i <= 2; i++) {
- var newBall = game.addChild(new Ball());
- newBall.x = ball.x;
- newBall.y = ball.y;
- var angle = i * 25 * (Math.PI / 180); // Convert degrees to radians
- newBall.speedX = -Math.cos(angle) * 15;
- newBall.speedY = Math.sin(angle) * 15;
- balls.push(newBall);
- }
// Calculate the difference between the center of the ball and the center of the paddle
var diffY = ball.y - aiPaddle.y;
// Normalize the difference to get a value between -1 and 1
var normalizedDiffY = diffY / (aiPaddle.height / 2);
@@ -160,47 +138,25 @@
ball.speedX = -Math.cos(angle) * 5 * 3;
ball.speedY = Math.sin(angle) * 5 * 3;
}
// Check for scoring
- if (ball.x <= 0 && !pointScored) {
- pointScored = true;
+ if (ball.x <= 0) {
// Remove all existing balls
balls.forEach(function (ball) {
ball.destroy();
});
balls = [];
- // Create 5 new balls
- for (var i = 0; i < 5; i++) {
- var newBall = game.addChild(new Ball());
- newBall.x = 1024; // Center horizontally
- newBall.y = 1366; // Center vertically
- // Assign random speeds and directions
- newBall.speedX = (Math.random() < 0.5 ? -1 : 1) * (10 + Math.random() * 10);
- newBall.speedY = (Math.random() < 0.5 ? -1 : 1) * (10 + Math.random() * 10);
- balls.push(newBall);
- }
aiPaddle.score++; // Increase AI's score
aiScoreTxt.setText(aiPaddle.score); // Update AI's score display
// Add blood splatter effect
LK.effects.flashScreen(0xff0000, 100);
}
- if (ball.x >= 2048 && !pointScored) {
- pointScored = true;
+ if (ball.x >= 2048) {
// Remove all existing balls
balls.forEach(function (ball) {
ball.destroy();
});
balls = [];
- // Create 5 new balls
- for (var i = 0; i < 5; i++) {
- var newBall = game.addChild(new Ball());
- newBall.x = 1024; // Center horizontally
- newBall.y = 1366; // Center vertically
- // Assign random speeds and directions
- newBall.speedX = (Math.random() < 0.5 ? -1 : 1) * (10 + Math.random() * 10);
- newBall.speedY = (Math.random() < 0.5 ? -1 : 1) * (10 + Math.random() * 10);
- balls.push(newBall);
- }
playerPaddle.score++; // Increase player's score
playerScoreTxt.setText(playerPaddle.score); // Update player's score display
// Add blood splatter effect
LK.effects.flashScreen(0xff0000, 100);
@@ -210,17 +166,8 @@
// Flash screen red for 1 second (1000ms) to show game over.
LK.effects.flashScreen(0xff0000, 1000);
// Show game over. The game will be automatically paused while game over is showing.
LK.showGameOver(); // Calling this will destroy the 'Game' and reset entire game state.
- // Create 5 new balls
- for (var i = 0; i < 5; i++) {
- var newBall = game.addChild(new Ball());
- newBall.x = 1024; // Center horizontally
- newBall.y = 1366; // Center vertically
- // Assign random speeds and directions
- newBall.speedX = (Math.random() < 0.5 ? -1 : 1) * (10 + Math.random() * 10);
- newBall.speedY = (Math.random() < 0.5 ? -1 : 1) * (10 + Math.random() * 10);
- }
}
}
// Game tick
LK.on('tick', function () {