User prompt
Скорость вращения мяча уменьшается на 0.1 с каждым отскоком
User prompt
Скорость вращения мяча уменьшается с каждым отскоком на 0.12
User prompt
Скорость вращения мяча уменьшается с каждым отскоком на 0.5
User prompt
Скорость вращения мяча уменьшается с каждым отскоком на 0.2
User prompt
Скорость вращения мяча уменьшается с каждым отскоком на 0.1
User prompt
Скорость вращения мяча уменьшается с каждым скачком на 0.08
User prompt
Скорость вращения мяча зависит от силы броска, если сила броска максимальная, то скорость 0.99, если сила удара минимальная, то 0
User prompt
Мяч отскакивает от потолка
User prompt
Delete basket
User prompt
Уменьшить скорость вращения после каждого отскока на 0.1
User prompt
Когда мяч бросают, то мяч вращается вокруг своей оси, против часовой стрелки
User prompt
Мяч останавливается после 15 отскоков
User prompt
Мяч отскакивает от стен экрана
User prompt
Если мяч не подвижен в течение 2 секунд после броска, то проигрыш
User prompt
После 10 отскоков, мяч останавливается
User prompt
После 5 отскоков мяч останавливается
User prompt
После отскока, скорость мяча уменьшается в полтора раза, после каждого следующего отскока, скорость уменьшается на 0.2. Если скорость мяча меньше или равно 0.2 то мяч останавливается
User prompt
Мяч перестает отскакивать, если перемещение мяча после отскока меньше 15 пикселей и останавливается
User prompt
Мяч перестает отскакивать, если перемещение мяча после отскока меньше 15 пикселей
User prompt
Каждый отскок уменьшает скорость следующего отскока на 0.2. Если скорость следующего отскока должны быть 0.2, то мяч останавливается
User prompt
Каждый отскок уменьшает скорость после следующего отскока на 0.3
User prompt
Если мы неподвижен после броска 2 секунды, то он появляется заново в заданных начальных координатах
User prompt
Мяч отскакивает от Пола
User prompt
Если мы попал в ободок корзины, то отскок, кроме случае попадания мяча в верхнюю ось изображения корзины по середине и плюс минус 40 пикселей
User prompt
Если мяч пересек изображение сетки корзины, то отскок
/**** * Classes ****/ // Assets will be automatically created based on usage in the code. // 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 = 0; self.speedY = 0; self.isMoving = false; self.bounceCount = 0; // Add a bounce counter self.launch = function (speedX, speedY) { self.speedX = speedX; self.speedY = speedY; self.isMoving = true; self.bounceCount = 0; // Reset bounce counter on launch }; self.update = function () { if (self.isMoving && self.bounceCount < 10) { self.x += self.speedX; self.y += self.speedY; self.speedY += 0.98; // Gravity effect // If the ball's speed is very low, it's probably hanging in the air if (Math.abs(self.speedX) < 0.01 && Math.abs(self.speedY) < 0.01) { self.hangingTicks = (self.hangingTicks || 0) + 1; // If the ball has been hanging for more than 120 ticks (2 seconds), trigger loss if (self.hangingTicks > 120) { LK.effects.flashScreen(0xff0000, 1000); // Flash screen red for 1 second to indicate loss LK.showGameOver(); // Show game over screen } } else { self.hangingTicks = 0; } } }; self.reset = function () { self.x = 420; // Set x position self.y = 1790; // Set y position self.speedX = 0; self.speedY = 0; self.isMoving = false; self.bounceCount = 0; // Reset bounce counter on reset }; }); // Basket class var Basket = Container.expand(function () { var self = Container.call(this); var basketGraphics = self.attachAsset('basket', { anchorX: 0.5, anchorY: 0.5 }); }); // Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('Player', { anchorX: 0.5, anchorY: 0.5 }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Light blue background }); /**** * Game Code ****/ var background = game.addChild(LK.getAsset('Background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 2048 / 2732, scaleY: 2732 / 2732 })); var player = game.addChild(new Player()); player.x = player.width / 2; // Position on the left side of the screen player.y = 2732 - player.height / 2; // Position at the bottom of the screen var ball = game.addChild(new Ball()); ball.x = 420; ball.y = 1790; var baskets = []; var basket = game.addChild(new Basket()); basket.x = 2048 - basket.width / 2; // Position on the right side of the screen basket.y = 2732 / 2; // Center vertically baskets.push(basket); var lastTouchPosition = { x: 0, y: 0 }; game.on('down', function (obj) { var pos = obj.event.getLocalPosition(game); lastTouchPosition.x = pos.x; lastTouchPosition.y = pos.y; }); game.on('up', function (obj) { if (!ball.isMoving) { var pos = obj.event.getLocalPosition(game); var speedX = (pos.x - lastTouchPosition.x) / 10; var speedY = (pos.y - lastTouchPosition.y) / 10; ball.launch(speedX, speedY); } }); LK.on('tick', function () { ball.update(); // Check for collisions with baskets baskets.forEach(function (basket) { if (Math.hypot(ball.x - basket.x, ball.y - basket.y) < ball.width / 2 + basket.width / 2 && ball.y < basket.y && ball.x >= basket.x - 30 && ball.x <= basket.x + 30) { if (ball.y < basket.y + basket.height / 2) { LK.effects.flashScreen(0x00FF00, 500); // Flash green for success ball.reset(); LK.setScore(LK.getScore() + 1); // Increase the score by 1 } else if (ball.intersects(basket.net)) { // If the ball intersects with the basket net image // Make the ball bounce off at half speed ball.speedX = -ball.speedX / 1.5; ball.speedY = -ball.speedY / 1.5; ball.bounceCount++; // Increase bounce count } else { // If the ball is inside the basket, make it bounce off at half speed ball.speedX = -ball.speedX / 1.5; ball.speedY = -ball.speedY / 1.5; ball.bounceCount++; // Increase bounce count } } else if (Math.hypot(ball.x - basket.x, ball.y - basket.y) < ball.width / 2 + basket.width / 2) { // If the ball hits the basket from the sides or bottom, make it bounce off at half speed // Except when it hits the top center of the basket (within 40 pixels) if (!(ball.y < basket.y + basket.height / 2 && ball.x >= basket.x - 40 && ball.x <= basket.x + 40)) { ball.speedX = -ball.speedX / 1.5; ball.speedY = -ball.speedY / 1.5; ball.bounceCount++; // Increase bounce count } } }); // Bounce the ball off the left and right screen edges if (ball.x < ball.width / 2) { ball.speedX = -ball.speedX / 1.5; // Make the ball bounce off at half speed ball.bounceCount++; // Increase bounce count ball.x = ball.width / 2; // Correct the position to prevent the ball from going off screen } else if (ball.x > 2048 - ball.width / 2) { ball.speedX = -ball.speedX / 1.5; // Make the ball bounce off at half speed ball.bounceCount++; // Increase bounce count ball.x = 2048 - ball.width / 2; // Correct the position to prevent the ball from going off screen } // Bounce the ball off the floor if (ball.y > 2732 - ball.height / 2) { ball.speedY = -ball.speedY / 1.5; // Make the ball bounce off at half speed ball.bounceCount++; // Increase bounce count ball.y = 2732 - ball.height / 2; // Correct the position to prevent the ball from going off screen } });
===================================================================
--- original.js
+++ change.js
@@ -139,8 +139,18 @@
ball.bounceCount++; // Increase bounce count
}
}
});
+ // Bounce the ball off the left and right screen edges
+ if (ball.x < ball.width / 2) {
+ ball.speedX = -ball.speedX / 1.5; // Make the ball bounce off at half speed
+ ball.bounceCount++; // Increase bounce count
+ ball.x = ball.width / 2; // Correct the position to prevent the ball from going off screen
+ } else if (ball.x > 2048 - ball.width / 2) {
+ ball.speedX = -ball.speedX / 1.5; // Make the ball bounce off at half speed
+ ball.bounceCount++; // Increase bounce count
+ ball.x = 2048 - ball.width / 2; // Correct the position to prevent the ball from going off screen
+ }
// Bounce the ball off the floor
if (ball.y > 2732 - ball.height / 2) {
ball.speedY = -ball.speedY / 1.5; // Make the ball bounce off at half speed
ball.bounceCount++; // Increase bounce count
Basket. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Стена белая синия. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
граффити слово Swipe. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Граффити с текстом "after three bounces of the ball, a goal is scored". Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.