User prompt
add a CRT style shader over the game
User prompt
If the enemy scores three points, make it game over
User prompt
make the paddles flash when they hit the ball
User prompt
increase the width of the opponent paddle
User prompt
increase the speed of the ball
User prompt
increase the speed of the opponents paddle
User prompt
add a third sound for when the opponent scores against the player
User prompt
the paddlehit sound should only play when the ball hits the opponent or player paddle. add a second sound for when the player scores a point
User prompt
no sounds are playing when player or opponent paddle hits ball
User prompt
sounds arent working
User prompt
pad a sound when the player scores a point
User prompt
add a simple arcade sound when either paddle hits the ball
User prompt
add an 8bit sound when either paddle hits the ball
User prompt
you're only randomising the ball with two horizontal directions, but the ball should be able to shoot at the player in any horizontal direction
User prompt
add a white line around the arena
User prompt
increase the speed of the opponents paddle each time the player scores
User prompt
increase the opponents width and speed each time the player scores
User prompt
each time the enemy scores, increase the speed of the opponent paddle by 10%, and the width of the opponent paddle by 5%, until the players score reaches 10
User prompt
with each point the player scores, increase the width and speed of the enemy paddle slightly
User prompt
randomise the direction of the ball, but only on the Y axis, only ever send the first ball to the player
User prompt
randomise the direction of the ball
User prompt
make the middleLine setLineDash
User prompt
use setLineDash to make the horizontal middleLine dashed
User prompt
make the opacity of middleLine 100%
User prompt
make the horizontal line dotted
/**** * Classes ****/ // Ball class var Ball = Container.expand(function () { var self = Container.call(this); var ballGraphics = self.attachAsset('ball', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = 10; self.speedY = 10; self.update = function () { self.x += self.speedX; self.y += self.speedY; }; }); //<Assets used in the game will automatically appear here> // Paddle class for player and opponent var Paddle = Container.expand(function () { var self = Container.call(this); var paddleGraphics = self.attachAsset('paddle', { anchorX: 0.5, anchorY: 0.5, width: 300 }); self.width = paddleGraphics.width; self.height = paddleGraphics.height; self.update = function () { // Paddle update logic if needed }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x0000FF //Init game with blue background }); /**** * Game Code ****/ // Initialize paddles, ball and middle line var playerPaddle = new Paddle(); var opponentPaddle = new Paddle(); var ball = new Ball(); var middleLine = LK.getAsset('middleLine', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); middleLine.alpha = 1; game.addChild(middleLine); var topBorder = LK.getAsset('arenaBorder', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 0 }); game.addChild(topBorder); // Initialize player and opponent scores var playerScore = 0; var opponentScore = 0; // Position paddles and ball playerPaddle.x = 2048 / 2; playerPaddle.y = 2732 - 100; opponentPaddle.x = 2048 / 2; opponentPaddle.y = 100; ball.x = 2048 / 2; ball.y = 2732 / 2; // Add paddles and ball to the game game.addChild(playerPaddle); game.addChild(opponentPaddle); game.addChild(ball); // Create score display text for player and opponent var playerScoreTxt = new Text2('0', { size: 100, fill: "#ffffff", font: "'GillSans-Bold',Impact,'Arial Black',Tahoma" }); var opponentScoreTxt = new Text2('0', { size: 100, fill: "#ffffff", font: "'GillSans-Bold',Impact,'Arial Black',Tahoma" }); // Position score display text playerScoreTxt.x = 100; playerScoreTxt.y = middleLine.y + 100; opponentScoreTxt.x = 100; opponentScoreTxt.y = middleLine.y - 200; // Add score display text to the game game.addChild(playerScoreTxt); game.addChild(opponentScoreTxt); var bottomBorder = LK.getAsset('arenaBorder', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 }); game.addChild(bottomBorder); var leftBorder = LK.getAsset('arenaBorder', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 2732 / 2, rotation: 1 }); game.addChild(leftBorder); var rightBorder = LK.getAsset('arenaBorder', { anchorX: 0.5, anchorY: 0.5, x: 2048, y: 2732 / 2, rotation: 1 }); game.addChild(rightBorder); // Handle player paddle movement game.move = function (x, y, obj) { playerPaddle.x = x; }; // Update game logic game.update = function () { // Update ball position ball.update(); // Check for collisions with paddles if (ball.intersects(playerPaddle)) { ball.speedY *= -1; ball.y = playerPaddle.y - playerPaddle.height / 2 - ball.height / 2; } if (ball.intersects(opponentPaddle)) { ball.speedY *= -1; ball.y = opponentPaddle.y + opponentPaddle.height / 2 + ball.height / 2; } // Check for wall collisions if (ball.x <= 0 || ball.x >= 2048) { ball.speedX *= -1; } // Check for scoring if (ball.y <= 0 || ball.y >= 2732) { // Update scores if (ball.y <= 0) { playerScore += 1; playerScoreTxt.setText(playerScore.toString()); opponentScoreTxt.setText(opponentScore.toString()); // Increase the opponent's paddle speed each time the player scores opponentPaddle.speed += 1; } else if (ball.y >= 2732) { opponentScore += 1; } // Reset ball position ball.x = 2048 / 2; ball.y = 2732 / 2; ball.speedY = 0; ball.speedX = 0; // Add a 1 second timer before the ball starts playing again LK.setTimeout(function () { ball.speedY = 10; // Always send the first ball to the player ball.speedX = Math.random() > 0.5 ? 10 : -10; // Randomise the direction on the X axis }, 1000); } // Simple AI for opponent paddle with increased speed if (ball.x < opponentPaddle.x) { opponentPaddle.x -= 10; } else if (ball.x > opponentPaddle.x) { opponentPaddle.x += 10; } };
===================================================================
--- original.js
+++ change.js
@@ -52,8 +52,15 @@
y: 2732 / 2
});
middleLine.alpha = 1;
game.addChild(middleLine);
+var topBorder = LK.getAsset('arenaBorder', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 0
+});
+game.addChild(topBorder);
// Initialize player and opponent scores
var playerScore = 0;
var opponentScore = 0;
// Position paddles and ball
@@ -85,8 +92,31 @@
opponentScoreTxt.y = middleLine.y - 200;
// Add score display text to the game
game.addChild(playerScoreTxt);
game.addChild(opponentScoreTxt);
+var bottomBorder = LK.getAsset('arenaBorder', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732
+});
+game.addChild(bottomBorder);
+var leftBorder = LK.getAsset('arenaBorder', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 0,
+ y: 2732 / 2,
+ rotation: 1
+});
+game.addChild(leftBorder);
+var rightBorder = LK.getAsset('arenaBorder', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048,
+ y: 2732 / 2,
+ rotation: 1
+});
+game.addChild(rightBorder);
// Handle player paddle movement
game.move = function (x, y, obj) {
playerPaddle.x = x;
};