User prompt
The bounce of the ball depends on the arc of the Air hockey mallet, in which direction it bounces.
User prompt
move the table down with 500 units
User prompt
Add to the game a white background asset.
User prompt
Change the player paddle movement to follow the finger position
Initial prompt
vertical pong
/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Ball class var Ball = Container.expand(function () { var self = Container.call(this); var ballGraphics = self.attachAsset('ball', { anchorX: 0.5, anchorY: 0.5 }); self.speedY = 10; self.update = function () { self.y += self.speedY; if (self.y <= 0 || self.y >= 2732) { self.speedY *= -1; } }; }); // Paddle class var Paddle = Container.expand(function () { var self = Container.call(this); var paddleGraphics = self.attachAsset('paddle', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Paddle update logic if needed }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Attach white background asset var background = LK.getAsset('background', { anchorX: 0.0, anchorY: 0.0, x: 0, y: 0 }); game.addChild(background); // Initialize ball and paddle var ball = game.addChild(new Ball()); ball.x = 2048 / 2; ball.y = 2732 / 2; var paddle = game.addChild(new Paddle()); paddle.x = 2048 / 2; paddle.y = 2500 + 500; // Score display var score = 0; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Handle paddle movement game.move = function (x, y, obj) { paddle.x = x; paddle.y = y; }; // Update game logic game.update = function () { ball.update(); paddle.update(); // Check for collision between ball and paddle if (ball.intersects(paddle)) { ball.speedY *= -1; score++; scoreTxt.setText(score); } // Check if ball hits the bottom of the screen if (ball.y >= 2732) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } };
===================================================================
--- original.js
+++ change.js
@@ -52,9 +52,9 @@
ball.x = 2048 / 2;
ball.y = 2732 / 2;
var paddle = game.addChild(new Paddle());
paddle.x = 2048 / 2;
-paddle.y = 2500;
+paddle.y = 2500 + 500;
// Score display
var score = 0;
var scoreTxt = new Text2('0', {
size: 150,
New ball button. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
air hockey table with neon lights. top view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Air hockey disk with neon green lights. top view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Air hockey disk with neon yellow lights. top view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Air hockey disk with neon orange lights. top view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.