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
===================================================================
--- original.js
+++ change.js
@@ -106,19 +106,36 @@
bullets.splice(i, 1);
}
}
});
-// Simple touch controls to change plane directions
+// 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, change plane1 direction
+ // 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 / 12; // Add 15 degrees (in radians)
plane1.speedX = Math.cos(angle) * 5;
plane1.speedY = Math.sin(angle) * 5;
- } else {
- // If touch is on the right half, change plane2 direction
+ }
+ if (isTouchingRight) {
var angle = Math.atan2(plane2.speedY, plane2.speedX);
angle += Math.PI / 12; // Add 15 degrees (in radians)
plane2.speedX = Math.cos(angle) * 5;
plane2.speedY = Math.sin(angle) * 5;
снаряд от пушки. 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.