User prompt
После поворота добавить скорость разгона начиная 4 и до 7 для игрока и противника
User prompt
Please fix the bug: 'TypeError: LK.showPauseScreen is not a function. (In 'LK.showPauseScreen()', 'LK.showPauseScreen' is undefined)' in or related to this line: 'LK.showPauseScreen();' Line Number: 255
User prompt
Please fix the bug: 'TypeError: LK.pauseGame is not a function. (In 'LK.pauseGame()', 'LK.pauseGame' is undefined)' in or related to this line: 'LK.pauseGame();' Line Number: 255
User prompt
Если противник пересек 950 от центра, то игра останавливается на 1 секунду
User prompt
Please fix the bug: 'TypeError: undefined is not an object (evaluating 'localStorage.setItem')' in or related to this line: 'localStorage.setItem('score', LK.getScore());' Line Number: 246
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'var score = localStorage.getItem('score') || '0';' Line Number: 255
User prompt
Сохранять количество набранных очков
Code edit (1 edits merged)
Please save this source code
User prompt
Сделать score черным
User prompt
Подвинуть score в правый верхний угол
Code edit (1 edits merged)
Please save this source code
User prompt
После смерти противника, прибавлять одну очко к score
User prompt
Выводить score вверху в центре
User prompt
Исправить ошибку, когда игрок после смерти противника двигается вертикально с неверным положении машины
User prompt
Исправить ошибку, когда игрок после смерти противника двигается по диагонали, а не вертикально Вверх
User prompt
Исправить ошибку, когда игрок после смерти противника двигается по диагонали, а не вертикально
User prompt
После смерти противника, игрок перемещается на начальную точки и двигается по вертикали
User prompt
Если противник пересек границу радиусом 950 от центра, то он и игрок появляется на точке респауна, при этом текущее направление у игрока сбрасывает
User prompt
Если противник пересек границу радиусом 950 от центра, то он и игрок появляется на точке респауна и начинают движение по вертикали друг к другу
User prompt
Если противник пересек границу радиусом 950 от центра, то он и игрок появляется на точке респауна
User prompt
При пересечении противником радиуса 950 от центра, противник моргает 2 секунды и потом появляется в месте возрождения
User prompt
При пересечении противником радиуса 950 от центра, противник появляется месте возрождения
User prompt
Сделать более точную проверку на пересечение игрока и противоика
User prompt
Исправить ошибку, когда противники при повороте не скользят
User prompt
Исправить ошибку, когда все противники остановились и перестали преследовать ближайшую цель
===================================================================
--- original.js
+++ change.js
@@ -76,21 +76,10 @@
self.speedX = 0;
self.speedY = 0;
// Move enemy based on its speed
self.move = function () {
- // Add a sliding effect when the enemy is turning
- if (self.slidingDuration > 0) {
- self.x += self.speedX;
- self.y += self.speedY;
- self.slidingDuration--;
- if (self.slidingDuration === 0) {
- self.speedX = Math.sin(self.rotation) * 7;
- self.speedY = -Math.cos(self.rotation) * 7;
- }
- } else {
- self.x += self.speedX;
- self.y += self.speedY;
- }
+ self.x += self.speedX;
+ self.y += self.speedY;
};
// Prevent the enemy from moving in the opposite direction when it hits the wall
self.checkBounds = function () {
if (self.x < 0) {
@@ -109,15 +98,31 @@
var dx = player.x - self.x;
var dy = player.y - self.y;
// Normalize the direction vector
var length = Math.sqrt(dx * dx + dy * dy);
- if (length > 0) {
- dx /= length;
- dy /= length;
- }
+ dx /= length;
+ dy /= length;
// Set the enemy's speed to move towards the player
- self.speedX = dx * 7;
- self.speedY = dy * 7;
+ // Add sliding behavior to the enemy car
+ self.speedX += dx * 0.05;
+ self.speedY += dy * 0.05;
+ if (self.slidingDuration > 0) {
+ self.slidingDuration--;
+ if (self.slidingDuration === 0) {
+ // Calculate the direction vector from the enemy to the player
+ var dx = player.x - self.x;
+ var dy = player.y - self.y;
+ // Normalize the direction vector
+ var length = Math.sqrt(dx * dx + dy * dy);
+ dx /= length;
+ dy /= length;
+ // Set the enemy's speed to always be 7
+ self.speedX = dx * 7;
+ self.speedY = dy * 7;
+ }
+ } else {
+ self.slidingDuration = 90; // Set sliding duration to 2 seconds (120 frames)
+ }
// Calculate the angle of the direction vector
var angle = Math.atan2(dy, dx);
// Rotate the enemy car to face the player and adjust by -90 degrees
self.rotation = angle - Math.PI / 2;
@@ -151,26 +156,8 @@
enemy.speedX = 0;
enemy.speedY = 7;
cars.push(enemy);
game.addChildAt(enemy, game.children.length);
-// Create an enemy2 car
-var enemy2 = new Enemy();
-enemy2.x = 2048 / 2 + 850; // Right side of the circle
-enemy2.y = 1366; // Top of the screen
-enemy2.speedX = -7; // Set initial horizontal speed
-enemy2.speedY = 0;
-enemy2.rotation = Math.PI / 2; // Rotate by 90 degrees
-cars.push(enemy2);
-game.addChildAt(enemy2, game.children.length);
-// Create an enemy3 car
-var enemy3 = new Enemy();
-enemy3.x = 2048 / 2 - 850; // Left side of the circle
-enemy3.y = 1366; // Top of the screen
-enemy3.speedX = 7; // Set initial horizontal speed
-enemy3.speedY = 0;
-enemy3.rotation = -Math.PI / 2; // Rotate by -90 degrees
-cars.push(enemy3);
-game.addChildAt(enemy3, game.children.length);
// Create a background for the game
var background = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
@@ -193,41 +180,45 @@
LK.on('tick', function () {
cars.forEach(function (car) {
car.move();
car.checkBounds();
- if (car === enemy || car === enemy2 || car === enemy3) {
- if (LK.ticks > 120) {
+ if (car === enemy) {
+ if (LK.ticks > 90) {
// Delay of 1.5 seconds (60 ticks per second)
car.followPlayer(cars[0]); // Assume the player car is the first car in the array
}
}
// Check for collisions with other cars
cars.forEach(function (otherCar) {
- if (car !== otherCar && car.intersects(otherCar, 80, 80)) {
- // On collision, move both cars 200 pixels back in the direction opposite to the point of intersection
+ if (car !== otherCar) {
+ // Calculate the distance between the centers of the two cars
var dx = car.x - otherCar.x;
var dy = car.y - otherCar.y;
var distance = Math.sqrt(dx * dx + dy * dy);
- var moveDistance = 60;
- var moveStep = moveDistance / 10; // 60 frames for 1 second of smooth movement
- var moveX = dx / distance * moveStep;
- var moveY = dy / distance * moveStep;
- var moveCounter = 0;
- var moveInterval = LK.setInterval(function () {
- car.x += moveX;
- car.y += moveY;
- otherCar.x -= moveX;
- otherCar.y -= moveY;
- moveCounter++;
- if (moveCounter >= 10) {
- LK.clearInterval(moveInterval);
- }
- }, 1000 / 60); // 60 FPS
+ // Check if the distance is less than the sum of the radii of the two cars
+ if (distance < car.width / 2 + otherCar.width / 2) {
+ // On collision, move both cars 200 pixels back in the direction opposite to the point of intersection
+ var moveDistance = 60;
+ var moveStep = moveDistance / 10; // 60 frames for 1 second of smooth movement
+ var moveX = dx / distance * moveStep;
+ var moveY = dy / distance * moveStep;
+ var moveCounter = 0;
+ var moveInterval = LK.setInterval(function () {
+ car.x += moveX;
+ car.y += moveY;
+ otherCar.x -= moveX;
+ otherCar.y -= moveY;
+ moveCounter++;
+ if (moveCounter >= 10) {
+ LK.clearInterval(moveInterval);
+ }
+ }, 1000 / 60); // 60 FPS
+ }
}
});
// Check if the car is outside the circle
var distanceFromCenter = Math.sqrt(Math.pow(car.x - 2048 / 2, 2) + Math.pow(car.y - 2732 / 2, 2));
- if (distanceFromCenter > 970 && car !== enemy && car !== enemy2 && car !== enemy3) {
+ if (distanceFromCenter > 970) {
LK.showGameOver();
}
});
});
Лава мультяшная вид сверху плоская. Single Game Texture. In-Game asset. 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.
шины на асфальте после торможения для игры. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.