User prompt
при сталкновении самолета с потолком или полом game over
User prompt
при сталкновении со стеной самолет появляется с другой стороны стены
User prompt
менять направление движения на 2 градуса
User prompt
менять направление движения на 4 градуса
Code edit (1 edits merged)
Please save this source code
User prompt
менять направление движения не на 15 градусов, а на 1 градус
User prompt
после нажатия и удерживания на экран направление движения против часовой стрелке
User prompt
если происходит удерживание по экрану, то самолет продолжается поворачиваться
User prompt
после нажатия на экран, направление движения самолета меняется на 15 градусов
Initial prompt
planes wars
/**** * 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 = -10; // Move bullet self.move = function () { self.y += self.speed; }; }); // Assets are automatically created based on usage in the code. // Plane class var Plane = Container.expand(function () { var self = Container.call(this); // Initialize plane with a shape asset var planeGraphics = self.attachAsset('plane', { width: 60, height: 60, color: 0xff0000, // Default red, will be overridden shape: 'ellipse' }); self.speedX = 0; self.speedY = 0; // Method to update plane position self.update = function () { self.x += self.speedX; self.y += self.speedY; // Make the plane appear on the opposite side of the screen when it hits a wall if (self.x < 0) { self.x = 2048; } else if (self.x > 2048) { self.x = 0; } if (self.y < 0 || self.y > 2732) { LK.showGameOver(); } }; // Method to shoot a bullet self.shoot = function () { var bullet = new Bullet(); bullet.x = self.x; bullet.y = self.y; bullets.push(bullet); game.addChild(bullet); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ var bullets = []; // Global array to keep track of bullets // Create two planes var plane1 = new Plane(); plane1.x = 200; plane1.y = 200; plane1.speedX = 5; plane1.speedY = 3; plane1.attachAsset('plane', { color: 0x0000ff }); // Blue color for plane1 var plane2 = new Plane(); plane2.x = 1848; // Start from the opposite side plane2.y = 2532; plane2.speedX = -5; plane2.speedY = -3; plane2.attachAsset('plane', { color: 0xff0000 }); // Red color for plane2 // Add planes to the game game.addChild(plane1); game.addChild(plane2); // Set up game tick LK.on('tick', function () { plane1.update(); plane2.update(); // Planes shoot bullets periodically if (LK.ticks % 60 == 0) { plane1.shoot(); plane2.shoot(); } // Update and check bullets for (var i = bullets.length - 1; i >= 0; i--) { bullets[i].move(); // Check for bullet collision with planes if (bullets[i].intersects(plane1) || bullets[i].intersects(plane2)) { // For simplicity, just remove the bullet on collision bullets[i].destroy(); bullets.splice(i, 1); } else if (bullets[i].y < -50 || bullets[i].y > 2782) { // Remove off-screen bullets 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) { var angle = Math.atan2(plane1.speedY, plane1.speedX); angle -= Math.PI / 90; // Subtract 2 degrees (in radians) for counter-clockwise rotation plane1.speedX = Math.cos(angle) * 5; plane1.speedY = Math.sin(angle) * 5; } if (isTouchingRight) { var angle = Math.atan2(plane2.speedY, plane2.speedX); angle -= Math.PI / 90; // Subtract 2 degrees (in radians) for counter-clockwise rotation plane2.speedX = Math.cos(angle) * 5; plane2.speedY = Math.sin(angle) * 5; } });
===================================================================
--- original.js
+++ change.js
@@ -39,12 +39,10 @@
self.x = 2048;
} else if (self.x > 2048) {
self.x = 0;
}
- if (self.y < 0) {
- self.y = 2732;
- } else if (self.y > 2732) {
- self.y = 0;
+ if (self.y < 0 || self.y > 2732) {
+ LK.showGameOver();
}
};
// Method to shoot a bullet
self.shoot = function () {
снаряд от пушки. 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.