User prompt
Please fix the bug: 'ReferenceError: isTouchingLeft is not defined' in or related to this line: 'if (isTouchingLeft) {' Line Number: 275
User prompt
добавить механику поворотов противнику как у игрока, но без условий нажатия по экрану
User prompt
при изменении направления, противник разворачивается по окружности по 1 градусу в направлении движения
User prompt
при изменении направления, противник разворачивается по окружности в направлении движения
User prompt
противник, когда временно не преследует игрока а меняет направление на 3 секунды, может изменить направление на случайное +- 15 градусов, от текущего направления
User prompt
противник, когда временно не преследует игрока а меняет направление на 3 секунды, может изменить направление на случайное +- 30 градусов, от текущего направления
User prompt
добавить такое условие для противника var isTouchingLeft = false; var isTouchingRight = false; // Change plane direction when the screen is touched var initialTouchPosition = null; game.on('down', function (obj) { initialTouchPosition = obj.event.getLocalPosition(game); }); game.on('move', function (obj) { if (initialTouchPosition) { var currentTouchPosition = obj.event.getLocalPosition(game); var swipeDirection = currentTouchPosition.x - initialTouchPosition.x; if (swipeDirection < 0) { isTouchingLeft = true; isTouchingRight = false; } else if (swipeDirection > 0) { isTouchingRight = true; isTouchingLeft = false;
Code edit (1 edits merged)
Please save this source code
User prompt
добавить такое условие для противника var angle = Math.atan2(plane1.speedY, plane1.speedX); angle += Math.PI / 60; // Add 1.5 degrees (in radians) for clockwise rotation plane1.speedX = Math.cos(angle) * 7; plane1.speedY = Math.sin(angle) * 7; plane1.rotation += Math.PI / 60; /
User prompt
добавить такое условие для противника var angle = Math.atan2(plane1.speedY, plane1.speedX); angle -= Math.PI / 60; // Subtract 1.5 degrees (in radians) for counter-clockwise rotation plane1.speedX = Math.cos(angle) * 7; plane1.speedY = Math.sin(angle) * 7; plane1.rotation -= Math.PI / 60; // Rotate the plane counter-clockwise
User prompt
чтобы противнику изменить движение, ему нужно сделать поворот изображением
User prompt
противник может лететь только по направлению движения
User prompt
сделать радиус поворота у противника
User prompt
сделать радиус поворота у бота 1.5 градуса
User prompt
противник преследует игрока 5 секунд, затем следующие 3 секунды не преследует, а продолжает двигаться в случайном направлении но по направлению винта, потом повторяется снова
User prompt
противник преследует игрока 5 секунд, затем следующие 3 секунды не преследует, а продолжает двигаться в случайном направлении, потом повторяется снова
User prompt
противник преследует игрока 5 секунд, затем следующие 3 секунды не преследует, потом повторяется снова
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'counter')' in or related to this line: 'self.counter++;' Line Number: 224
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'counter')' in or related to this line: 'self.counter++;' Line Number: 225
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'counter')' in or related to this line: 'self.counter++;' Line Number: 224
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'counter')' in or related to this line: 'self.counter++;' Line Number: 225
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'counter')' in or related to this line: 'self.counter++;' Line Number: 224
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'counter')' in or related to this line: 'self.counter++;' Line Number: 223
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'counter')' in or related to this line: 'self.counter++;' Line Number: 222
User prompt
противник преследует игрока, но раз в 3 секунды летит в другом направлении 2 секунды, потом повторяется
===================================================================
--- original.js
+++ change.js
@@ -41,20 +41,19 @@
} else if (self.y > 2752 - self.height) {
self.y = 2752 - self.height;
self.speedY = 0;
}
- // Rotate the enemy image smoothly, the right side sets the direction of the enemy
- var targetAngle = Math.atan2(-self.speedY, -self.speedX);
- var diff = targetAngle - enemyGraphics.rotation;
- if (diff > Math.PI) {
- diff -= 2 * Math.PI;
- } else if (diff < -Math.PI) {
- diff += 2 * Math.PI;
- }
- if (diff > 0) {
- enemyGraphics.rotation += Math.min(diff, Math.PI / 180);
+ // Rotate the enemy image in a circular motion towards the new direction
+ var targetAngle = Math.atan2(self.speedY, self.speedX) + Math.PI; // Adjust for enemy's forward direction
+ var currentAngle = enemyGraphics.rotation;
+ // Calculate shortest path to target angle
+ var angleDifference = targetAngle - currentAngle;
+ angleDifference -= Math.floor((angleDifference + Math.PI) / (2 * Math.PI)) * (2 * Math.PI);
+ // Rotate smoothly towards the target angle
+ if (angleDifference > 0) {
+ enemyGraphics.rotation += Math.min(angleDifference, Math.PI / 30); // Rotate clockwise
} else {
- enemyGraphics.rotation += Math.max(diff, -Math.PI / 180);
+ enemyGraphics.rotation += Math.max(angleDifference, -Math.PI / 30); // Rotate counter-clockwise
}
};
});
// Plane1 class
снаряд от пушки. 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.
Нажатие по экрану. Палец. Мультяшный. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.