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
@@ -199,31 +199,41 @@
var enemyBot = new EnemyBot();
enemyBot.x = 1900;
enemyBot.y = 2750 - enemyBot.height; // Bottom of the screen
game.addChild(enemyBot);
+// Add a variable to track the enemy's state and time since state change
+enemyBot.state = 'chasing';
+enemyBot.stateTime = 0;
// Create a plane
// Set up game tick
LK.on('tick', function () {
plane1.update();
- // Implement enemy chasing and random movement behavior
- var chaseTime = 300; // 5 seconds at 60FPS
- var randomMoveTime = 180; // 3 seconds at 60FPS
- if (LK.ticks % (chaseTime + randomMoveTime) < chaseTime) {
- // Enemy chases player for 5 seconds
- 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;
+ // Update the enemy's state and behavior based on the state
+ enemyBot.stateTime++;
+ if (enemyBot.state === 'chasing') {
+ if (enemyBot.stateTime >= 300) {
+ // 5 seconds * 60 FPS
+ enemyBot.state = 'wandering';
+ enemyBot.stateTime = 0;
+ // Set the enemy's speed to a random direction
+ var angle = Math.random() * 2 * Math.PI;
+ enemyBot.speedX = Math.cos(angle) * 5;
+ enemyBot.speedY = Math.sin(angle) * 5;
+ } else {
+ // Follow the player's plane
+ 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;
+ }
}
- } else {
- // Enemy moves in a random direction for 3 seconds
- if (LK.ticks % 60 == 0) {
- // Change direction every second
- var randomAngle = Math.random() * Math.PI * 2;
- enemyBot.speedX = Math.cos(randomAngle) * 5;
- enemyBot.speedY = Math.sin(randomAngle) * 5;
+ } else if (enemyBot.state === 'wandering') {
+ if (enemyBot.stateTime >= 180) {
+ // 3 seconds * 60 FPS
+ enemyBot.state = 'chasing';
+ enemyBot.stateTime = 0;
}
}
enemyBot.update();
// Plane shoots a bullet every 0.8 seconds
снаряд от пушки. 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.