User prompt
пересечение объектов игрока и противника в радиусе изображения, а не объекта
User prompt
пересечение игрока и противника проверяется по изображению картинки игрока X=90 y=190
User prompt
исправить ошибку, когда столкновение еще не произошло, а уже game over
User prompt
пересечение игрока и противника проверяется по изображению картинок, а не по X=200 y=100
Code edit (1 edits merged)
Please save this source code
User prompt
изменить скорость поворота с 1 градуса на 0.5 градуса
User prompt
скорость поворота у противника = 1 градус
User prompt
при преследовании игрока, противник плавно разворачивается = 1 градус
User prompt
правая сторона задает направление противника
User prompt
поворачивать плавно изображение противника, левая сторона задает направление противника
User prompt
противник преследует цель столкновения с игроком и летит за ним
Code edit (2 edits merged)
Please save this source code
User prompt
сделать проверку пересечение изображений в рамках x=200, y=100
User prompt
самолет должен летать между боковыми стенами без game over
User prompt
добавить такую же проверку по X координате
User prompt
исправить ошибку, когда столкновении игрока и противника засчитывается после того, как они уже врезались
User prompt
сделать смерить при столкновении в радиусе изображения, а не объекта
Code edit (1 edits merged)
Please save this source code
User prompt
добавить противника бота, который летает по карте и пытается убить игрока
User prompt
противник начинает движение горизонтально, а потом может двигаться вертикально
User prompt
противник не может пересечь health_bar
Code edit (1 edits merged)
Please save this source code
User prompt
механика поворотов противника, такая же как у игрока
User prompt
против летит 2 секунды горизонтально, потом направление раномно меняется
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -16,51 +16,36 @@
self.x += self.speedX;
self.y += self.speedY;
};
});
-// EnemyPlane class
-var EnemyPlane = Container.expand(function () {
+// EnemyBot class
+var EnemyBot = Container.expand(function () {
var self = Container.call(this);
- var enemyPlaneGraphics = self.attachAsset('enemy', {
+ var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speedX = -5;
+ self.speedX = 5;
self.speedY = 0;
- // Update enemy plane position
+ // Update enemy bot position
self.update = function () {
- // If the plane has been flying horizontally for 120 frames (2 seconds at 60FPS)
- if (LK.ticks % 120 == 0) {
- // Change the plane's movement to vertical
- self.speedX = 0;
- self.speedY = 5;
- }
self.x += self.speedX;
self.y += self.speedY;
+ // Check if the enemy bot has crossed the screen boundary
if (self.x < 0) {
self.x = 2048;
} else if (self.x > 2048) {
self.x = 0;
}
- if (self.y < healthBar.height) {
- self.y = healthBar.height;
+ // Prevent the enemy bot from crossing the floor and ceiling
+ if (self.y < 0) {
+ self.y = 0;
self.speedY = 0;
- } else if (self.y > 2732 - self.height) {
- self.y = 2732 - self.height;
+ } else if (self.y > 2752 - self.height) {
+ self.y = 2752 - self.height;
self.speedY = 0;
}
};
- self.shoot = function () {
- var bullet = new Bullet();
- var planeBackX = self.x - self.width / 2 * Math.cos(self.rotation);
- var planeBackY = self.y - self.width / 2 * Math.sin(self.rotation);
- bullet.x = planeBackX;
- bullet.y = planeBackY;
- bullet.speedX = 2 * self.speedX;
- bullet.speedY = 2 * self.speedY;
- bullets.push(bullet);
- game.addChild(bullet);
- };
});
// Plane1 class
var Plane1 = Container.expand(function () {
var self = Container.call(this);
@@ -107,22 +92,16 @@
/****
* Initialize Game
****/
-// Enemy plane class removed
// Assets are automatically created based on usage in the code.
var game = new LK.Game({
backgroundColor: 0xffffff // Init game with white background
});
/****
* Game Code
****/
-// Create an enemy plane
-var enemyPlane = new EnemyPlane();
-enemyPlane.x = 1950;
-enemyPlane.y = 2750 - enemyPlane.height;
-game.addChild(enemyPlane);
// Add health_bar to the top of the game
var healthBar = LK.gui.top.attachAsset('health_bar', {
anchorX: 0.5,
anchorY: 0
@@ -167,21 +146,30 @@
healthBar.setChildIndex(heart3, healthBar.children.length - 1);
} else {
healthBar.addChild(heart3);
}
-// Add death image to the health_bar
-var deathImage = healthBar.attachAsset('death', {
+// Add death image to the game at position X=500, Y=100
+var deathImage = game.attachAsset('death', {
anchorX: 0.5,
anchorY: 0.5
});
-deathImage.x = -600;
-deathImage.y = 90;
+deathImage.x = 300;
+deathImage.y = 300;
// Ensure the death image is always in the foreground
-if (healthBar.children.length > 0) {
- healthBar.setChildIndex(deathImage, healthBar.children.length - 1);
+if (game.children.length > 0) {
+ game.setChildIndex(deathImage, game.children.length - 1);
} else {
- healthBar.addChild(deathImage);
+ game.addChild(deathImage);
}
+// Add background2 to the middle of the game
+var background2 = game.attachAsset('background2', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1,
+ scaleY: 1
+});
+background2.x = 2175 / 2;
+background2.y = 2620 / 2;
// Add background to the bottom of the game
var background = game.attachAsset('background', {
anchorX: 0,
anchorY: 1,
@@ -190,21 +178,26 @@
});
background.y = 2732;
var bullets = []; // Global array to keep track of bullets
var bullets = []; // Global array to keep track of bullets
-// Create a player plane
+// Create a plane
var plane1 = new Plane1();
plane1.x = 100;
plane1.y = 2750 - plane1.height; // Bottom of the screen
game.addChild(plane1);
+// Create an enemy bot
+var enemyBot = new EnemyBot();
+enemyBot.x = 500;
+enemyBot.y = 2750 - enemyBot.height; // Bottom of the screen
+game.addChild(enemyBot);
+// Create a plane
// Set up game tick
LK.on('tick', function () {
plane1.update();
- enemyPlane.update();
+ enemyBot.update();
// Plane shoots a bullet every 0.8 seconds
if (LK.ticks % 48 == 0) {
plane1.shoot();
- enemyPlane.shoot();
}
// Update and check bullets
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].move();
@@ -257,10 +250,10 @@
plane1.speedX = Math.cos(angle) * 6;
plane1.speedY = Math.sin(angle) * 6;
plane1.rotation += Math.PI / 60; // Rotate the plane clockwise
}
- // Check if the plane touches the top or bottom of the screen or collides with the health_bar
- if (plane1.y <= 0 || plane1.y >= 2752 - plane1.height || plane1.intersects(healthBar)) {
+ // Check if the plane touches the top or bottom of the screen, collides with the health_bar, or collides with the enemy bot
+ if (plane1.y <= 0 || plane1.y >= 2752 - plane1.height || plane1.intersects(healthBar) || plane1.intersects(enemyBot)) {
// Trigger game over
LK.showGameOver();
}
});
\ No newline at end of file
снаряд от пушки. 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.