User prompt
добавить health_bar в верхнюю часть экрана
Code edit (1 edits merged)
Please save this source code
User prompt
увеличить границу пола на 50
User prompt
исправить ошибку, когда самолет сразу же врезается в пол
Code edit (15 edits merged)
Please save this source code
User prompt
самолет появляется в левой нижней части экрана
User prompt
удалить Background1
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
добавить Background2
Code edit (5 edits merged)
Please save this source code
User prompt
переместить background1 над background
User prompt
добавить картинку background1 в верхней части экрана
User prompt
добавить задний фон1
User prompt
смерть при касании потолка и пола не по объекту, а по изображению
User prompt
удалить задний фон сверху
User prompt
задний фон добавить в нижнюю часть экрана
User prompt
сделать задний фон форматов 2048 на 2732
User prompt
Отображать задний фон
User prompt
добавить background
Code edit (1 edits merged)
Please save this source code
User prompt
если самолет вращается вокруг своей оси, то и пули вылетают из дула самолета, а не из правой части картинки
User prompt
пуля вылетает из самолета
User prompt
установка скорости и направления пуль на основе текущей скорости и ориентации самолета в момент выстрела
User prompt
если самолет коснулся верхней части экрана game over
/****
* Classes
****/
// Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
width: 10,
height: 20,
color: 0xffffff,
shape: 'box'
});
self.speed = -20;
// Move bullet
self.move = function () {
self.x += self.speedX;
self.y += self.speedY;
};
});
// Plane1 class
var Plane1 = Container.expand(function () {
var self = Container.call(this);
var planeGraphics = self.attachAsset('plane', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = 5;
self.speedY = 0;
// Update plane position
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
// Check if the plane has crossed the screen boundary
if (self.x < 0) {
self.x = 2048;
} else if (self.x > 2048) {
self.x = 0;
}
// Prevent the plane from crossing the floor and ceiling
if (self.y < 0) {
self.y = 0;
} else if (self.y > 2732 - self.height) {
self.y = 2732 - self.height;
}
};
// Plane shoots a bullet
self.shoot = function () {
var bullet = new Bullet();
// Set bullet position to the front of the plane
bullet.x = self.x + self.width / 2 * Math.cos(self.rotation);
bullet.y = self.y + self.width / 2 * Math.sin(self.rotation);
// Set bullet speed to twice the plane's speed in the direction of the plane
bullet.speedX = 2 * self.speedX * Math.cos(self.rotation);
bullet.speedY = 2 * self.speedY * Math.sin(self.rotation);
game.addChild(bullet);
};
});
/****
* Initialize Game
****/
// Assets are automatically created based on usage in the code.
var game = new LK.Game({
backgroundColor: 0xffffff // Init game with white background
});
/****
* Game Code
****/
var bullets = []; // Global array to keep track of bullets
var bullets = []; // Global array to keep track of bullets
// Create a plane
var plane1 = new Plane1();
plane1.x = 0;
plane1.y = 2732 / 2; // Middle of the screen
game.addChild(plane1);
// Create a plane
// Set up game tick
LK.on('tick', function () {
plane1.update();
// Plane shoots a bullet once per second
if (LK.ticks % 60 == 0) {
plane1.shoot();
}
// Update and check bullets
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].move();
// Remove off-screen bullets
if (bullets[i].x > 2048) {
bullets[i].destroy();
bullets.splice(i, 1);
}
}
});
// Flags to track if the screen is being touched
var isTouchingLeft = false;
var isTouchingRight = false;
// Change plane direction when the screen is touched
game.on('down', function (obj) {
var pos = obj.event.getLocalPosition(game);
// If touch is on the left half of the screen, set isTouchingLeft to true
if (pos.x < 1024) {
isTouchingLeft = true;
} else {
// If touch is on the right half, set isTouchingRight to true
isTouchingRight = true;
}
});
// Stop changing plane direction when the screen is no longer being touched
game.on('up', function (obj) {
isTouchingLeft = false;
isTouchingRight = false;
});
// In the game tick, change plane direction while the screen is being touched
LK.on('tick', function () {
if (isTouchingLeft || isTouchingRight) {
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) * 5;
plane1.speedY = Math.sin(angle) * 5;
plane1.rotation -= Math.PI / 60; // Rotate the plane counter-clockwise
}
// Check if the plane touches the top or bottom of the screen
if (plane1.y <= 0 || plane1.y >= 2732 - plane1.height) {
// Trigger game over
LK.showGameOver();
}
});
снаряд от пушки. 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.