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
@@ -223,10 +223,28 @@
var dx = plane1.x - enemyBot.x;
var dy = plane1.y - enemyBot.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
- enemyBot.speedX = dx / distance * 5;
- enemyBot.speedY = dy / distance * 5;
+ var targetAngle = Math.atan2(dy, dx);
+ var currentAngle = Math.atan2(enemyBot.speedY, enemyBot.speedX);
+ var angleDifference = targetAngle - currentAngle;
+ // Adjust the angle difference to be between -pi and pi
+ if (angleDifference > Math.PI) {
+ angleDifference -= 2 * Math.PI;
+ } else if (angleDifference < -Math.PI) {
+ angleDifference += 2 * Math.PI;
+ }
+ // Limit the turning rate of the enemy
+ var maxTurningRate = Math.PI / 180; // 1 degree per frame
+ if (angleDifference > maxTurningRate) {
+ angleDifference = maxTurningRate;
+ } else if (angleDifference < -maxTurningRate) {
+ angleDifference = -maxTurningRate;
+ }
+ // Update the enemy's speed based on the new angle
+ var newAngle = currentAngle + angleDifference;
+ enemyBot.speedX = Math.cos(newAngle) * 5;
+ enemyBot.speedY = Math.sin(newAngle) * 5;
}
}
} else if (enemyBot.state === 'wandering') {
if (enemyBot.stateTime >= 180) {
@@ -280,16 +298,16 @@
// In the game tick, change plane direction while the screen is being touched
LK.on('tick', function () {
if (isTouchingLeft) {
var angle = Math.atan2(plane1.speedY, plane1.speedX);
- angle -= Math.PI / 120; // Subtract 1.5 degrees (in radians) for counter-clockwise rotation
+ 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
}
if (isTouchingRight && LK.ticks > 78) {
var angle = Math.atan2(plane1.speedY, plane1.speedX);
- angle += Math.PI / 120; // Add 1.5 degrees (in radians) for clockwise rotation
+ 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; // Rotate the plane clockwise
}
снаряд от пушки. 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.