Code edit (6 edits merged)
Please save this source code
User prompt
наклонить картинку napr на 10 градусов
Code edit (13 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: tap is not defined' in or related to this line: 'var originalScaleX = tap.scale.x;' Line Number: 136
User prompt
добавить картинку napr
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
удалять картинку tap после 3 секунд игры
User prompt
исправить ошибку, когда после двух уменьшений и увеличений картинки tap она не исчезает
User prompt
исправить ошибку, когда после двух уменьшений и увеличений картинки tap она не исчезает
User prompt
исправить ошибку, когда после двух уменьшений и увеличений картинки tap она не исчезает
User prompt
картинка tap уменьшается и увеличивается дважды, потом изчезает
User prompt
картинка tap уменьшается и увеличивается 2 раза
User prompt
Изображение tap уменьшается на 40 пикселей потом увеличивается обратно В течении 0.5 секунд. происходит 2 повторения и потом картинка исчезает
Code edit (1 edits merged)
Please save this source code
User prompt
Изображение tap уменьшается на 50 пикселей потом увеличивается обратно В течении 2 секунд
User prompt
Изображение tap уменьшается на 50 пикселей потом увеличивается обратно
User prompt
Изображение tap вращается против часовой стрелки на 10 градусов и потом возвращается в обратное положение.
User prompt
Добавить изображение tap в центр экрана
User prompt
Наклонить картинку napr на 5 градусов
User prompt
Поменять картинку ramk на napr
Code edit (3 edits merged)
Please save this source code
User prompt
Добавить изображение ramk в правую нижнюю сторону экрана
Code edit (1 edits merged)
Please save this source code
User prompt
Добавить картинку weapon в нижний центр экрана
/**** * Classes ****/ // Enemy class for targets var Enemy = Container.expand(function () { var self = Container.call(this); self.id = Math.floor(Math.random() * 10000); // Assign a random id to each enemy var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = Math.random() * (6 - 4) + 4; self.hit = false; self._move_migrated = function () { if (self.hit) { var angle = 70 * (Math.PI / 180); // Convert angle to radians self.x += 20 * Math.cos(angle); // Move horizontally based on the angle self.y += 20 * Math.sin(angle); // Move vertically based on the angle self.scale.x -= 20 / 60 / enemyGraphics.width; // Decrease width by 20 pixels per second self.scale.y -= 20 / 60 / enemyGraphics.height; // Decrease height by 20 pixels per second self.rotation += Math.PI / 4 / 60; // Rotate by 45 degrees per second } else { self.x += self.speed; if (self.id % 3 == 0) { self.y += 2 * Math.sin(LK.ticks / 60); // Move up and down smoothly by 30 } } }; }); // Assets are automatically created based on usage in the code. // Bullet class for bullets fired by the player var PlayerBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('playerBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -23; self._move_migrated = function () { self.x += self.speed * Math.cos(this.direction); self.y += self.speed * Math.sin(this.direction); self.scale.x -= 10 / 60 / bulletGraphics.width; // Decrease width by 3 pixels per second self.scale.y -= 10 / 60 / bulletGraphics.height; // Decrease height by 3 pixels per second }; self.distanceTo = function (other) { var dx = other.x - this.x; var dy = other.y - this.y; return Math.sqrt(dx * dx + dy * dy); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xFFFFFF // Init game with white background }); /**** * Game Code ****/ // Create a background var background = game.addChild(new Container()); var backgroundGraphics = background.attachAsset('background', { anchorX: 0.5, anchorY: 0.5 }); background.x = 1024; // Center horizontally background.y = 1366; // Center vertically var playerBullets = []; var enemies = []; var spawnEnemyInterval = 150; // Frames until next enemy spawns var enemySpawnTimer = 0; // Function to spawn enemies function spawnEnemy() { var enemySize = Math.random() * (200 - 130) + 130; var enemy = new Enemy(); enemy.scale.x = enemySize / 200; enemy.scale.y = enemySize / 200; enemy.x = -130; // Start at the left enemy.y = Math.random() * (1366 - 150) + 150; // Random position from 100 to 1366 enemies.push(enemy); game.addChild(enemy); } // Function to fire a bullet function fireBullet() { var bullet = new PlayerBullet(); bullet.x = 1024; // Center horizontally bullet.y = 2450; // Bottom of the screen playerBullets.push(bullet); game.addChild(bullet); return bullet; } // Touch event to fire bullets var lastBulletTime = 0; game.on('down', function (x, y, obj) { if (LK.ticks - lastBulletTime >= 60 || playerBullets.length === 0) { // 30 ticks = 0.5 second at 60FPS var bullet = fireBullet(); var touchPos = game.toLocal(obj.global); var angle = Math.atan2(2632 - touchPos.y, 1024 - touchPos.x); bullet.direction = angle; // Set direction to shoot towards the touch point lastBulletTime = LK.ticks; } }); // Add weapon image to the bottom center of the screen var weapon = game.addChild(new Container()); var weaponGraphics = weapon.attachAsset('weapon', { anchorX: 0.5, anchorY: 0.5 }); weapon.x = 1024; // Center horizontally weapon.y = 2632; // Bottom of the screen // Add 'tap' image to the center of the screen var tap = game.addChild(new Container()); var tapGraphics = tap.attachAsset('Tap', { anchorX: 0.5, anchorY: 0.5 }); tap.x = 1024; // Center horizontally tap.y = 1366; // Center vertically // Function to scale the 'tap' image down by 50 pixels and then scale it back up over 2 seconds function scaleTap() { var originalScaleX = tap.scale.x; var originalScaleY = tap.scale.y; var targetScaleX = (tapGraphics.width - 40) / tapGraphics.width; var targetScaleY = (tapGraphics.height - 40) / tapGraphics.height; var scaleCount = 0; // Scale down var scaleDownInterval = LK.setInterval(function () { if (tap.scale.x > targetScaleX && tap.scale.y > targetScaleY) { tap.scale.x -= 0.01 / 0.8; // Adjust for 2 seconds tap.scale.y -= 0.01 / 0.8; // Adjust for 2 seconds } else { LK.clearInterval(scaleDownInterval); // Scale up var scaleUpInterval = LK.setInterval(function () { if (tap.scale.x < originalScaleX && tap.scale.y < originalScaleY) { tap.scale.x += 0.01 / 0.8; // Adjust for 2 seconds tap.scale.y += 0.01 / 0.8; // Adjust for 2 seconds } else { LK.clearInterval(scaleUpInterval); scaleCount++; if (scaleCount < 2) { scaleTap(); } else { tap.visible = false; tap.destroy(); } } }, 16.67); // 60FPS } }, 16.67); // 60FPS } // Call the function to start the scaling scaleTap(); // Remove the 'tap' image after 3 seconds of gameplay LK.setTimeout(function () { tap.visible = false; tap.destroy(); }, 3000); // Main game loop LK.on('tick', function () { // Move bullets for (var i = playerBullets.length - 1; i >= 0; i--) { playerBullets[i]._move_migrated(); if (playerBullets[i].y < 0) { // Remove bullets that go off screen playerBullets[i].destroy(); playerBullets.splice(i, 1); } } // Move enemies for (var j = enemies.length - 1; j >= 0; j--) { enemies[j]._move_migrated(); if (enemies[j].y > 2300) { // Remove enemies that go off screen or become too small if (enemies[j].y > 2300 || enemies[j].scale.x <= 0 || enemies[j].scale.y <= 0) { enemies[j].destroy(); enemies.splice(j, 1); } } } // Check for collisions for (var b = playerBullets.length - 1; b >= 0; b--) { var bullet = playerBullets[b]; if (bullet) { for (var e = enemies.length - 1; e >= 0; e--) { var enemy = enemies[e]; if (enemy && !enemy.hit && bullet.intersects(enemy) && bullet.distanceTo(enemy) <= 100) { // Mark enemy as hit and destroy the bullet on collision bullet.destroy(); playerBullets.splice(b, 1); enemy.hit = true; break; // Exit loop after collision to avoid errors } } } } // Spawn enemies if (enemySpawnTimer <= 0) { spawnEnemy(); enemySpawnTimer = spawnEnemyInterval; } else { enemySpawnTimer--; } });
===================================================================
--- original.js
+++ change.js
@@ -153,8 +153,13 @@
}, 16.67); // 60FPS
}
// Call the function to start the scaling
scaleTap();
+// Remove the 'tap' image after 3 seconds of gameplay
+LK.setTimeout(function () {
+ tap.visible = false;
+ tap.destroy();
+}, 3000);
// Main game loop
LK.on('tick', function () {
// Move bullets
for (var i = playerBullets.length - 1; i >= 0; i--) {
черный шар. 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.
Белая мультяшная утка держит ружье и направляет в экран.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
вывеска на двух ниточках с надписью: TImakovDS. 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.