User prompt
первый круг всегда появляется в центре экрана
User prompt
исправить ошибку, когда не появляется новый круг
User prompt
скорость 10
User prompt
после того как шар попал в центр круга, в случайном месте появляется круг и шар перемещается в центр этого круга
User prompt
шар перемещается со статичной скоростью 5
User prompt
шар перемещается в центр круга
User prompt
добавить круг в центр экрана
Code edit (1 edits merged)
Please save this source code
User prompt
добавить шар в нижний центр
User prompt
задний фон темно серый
User prompt
удалить весь код, оставить только assets
User prompt
Шарик всегда двигается у центру круга
User prompt
После того как шарик достиг центра круга, появляется еще один круг и шарик двигается к центру нового круга
User prompt
Шарик движется в центр круга
User prompt
Добавить circle в центр хкрана
User prompt
Шарик появляется в нижней части экрана
User prompt
Увеличить скорость в 3 раза
User prompt
Шарик двигается по спирали
User prompt
Шарик не может менять направление движение больше чем на 45 градусов
User prompt
Скорость шарика от 3 до 6
User prompt
Скорость шарика от 5 до 8
User prompt
Скорость шарика от 8 до 12
User prompt
Сделать проверку на размер шарика перед отскоком
User prompt
Шарик меняет направление каждые 3 секунды
Initial prompt
Razduplis
/**** * 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.speedX = 5; self.speedY = 5; self.update = function () { // Calculate the direction vector from the ball to the center of the circle var directionX = 2048 / 2 - self.x; var directionY = 2732 / 2 - self.y; // Normalize the direction vector var length = Math.sqrt(directionX * directionX + directionY * directionY); directionX /= length; directionY /= length; // Move the ball in the direction of the circle self.x += directionX * self.speedX; self.y += directionY * self.speedY; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize ball var ball = game.addChild(new Ball()); ball.x = 2048 / 2; ball.y = 2732 - ball.height / 2; // Initialize circle var circle = game.addChild(LK.getAsset('Circle', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 })); // Update game every tick game.update = function () { ball.update(); };
===================================================================
--- original.js
+++ change.js
@@ -11,22 +11,18 @@
});
self.speedX = 5;
self.speedY = 5;
self.update = function () {
- self.x += self.speedX;
- self.y += self.speedY;
- // Check for collision with walls
- if (self.x - ballGraphics.width / 2 <= 0 || self.x + ballGraphics.width / 2 >= 2048) {
- self.speedX *= -1;
- }
- if (self.y - ballGraphics.height / 2 <= 0 || self.y + ballGraphics.height / 2 >= 2732) {
- self.speedY *= -1;
- }
- // Change direction every 3 seconds
- if (LK.ticks % 180 == 0) {
- self.speedX = Math.random() * 3 + 3;
- self.speedY = Math.random() * 3 + 3;
- }
+ // Calculate the direction vector from the ball to the center of the circle
+ var directionX = 2048 / 2 - self.x;
+ var directionY = 2732 / 2 - self.y;
+ // Normalize the direction vector
+ var length = Math.sqrt(directionX * directionX + directionY * directionY);
+ directionX /= length;
+ directionY /= length;
+ // Move the ball in the direction of the circle
+ self.x += directionX * self.speedX;
+ self.y += directionY * self.speedY;
};
});
/****
Песочные часы, черный. 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.
Шарик в круге, черный, иконка. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Carrot, черный цвет. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.