User prompt
добавить красный флеш скрин на game over
Code edit (1 edits merged)
Please save this source code
User prompt
исправить ошибку, когда противник пересек y=2000, но прозрачность idea не уменьшилась
User prompt
уменьшить прозрачность до 0 у IDEA, если противник пересек границу 2000
Code edit (11 edits merged)
Please save this source code
User prompt
если противник пересек y=2130, то изменить уменьшить прозрачность у IDEA До 0
User prompt
выводить game over с делеем 2 секунды
User prompt
сделать картинку IDEA прозрачной на 99 процентов
User prompt
просто добавить картинку IDEA без дополнительной логики
Code edit (4 edits merged)
Please save this source code
User prompt
повернуть изображение weapon на 30 градусов против часовой стрелки
Code edit (1 edits merged)
Please save this source code
User prompt
Убрать появление каждые 3 секунды у idea
User prompt
исправить ошибку когда после появления idea игра начинает лагать
User prompt
если противник пересек радиус 2130, то появляется картинка IDEA
Code edit (1 edits merged)
Please save this source code
User prompt
добавить новый объект IDEA
User prompt
добавить объект IDEA
User prompt
добавить объект idea в центр экрана
User prompt
Please fix the bug: 'Uncaught ReferenceError: tapGraphics is not defined' in or related to this line: 'var targetScaleX = (tapGraphics.width - 40) / tapGraphics.width;' Line Number: 239
User prompt
Please fix the bug: 'Uncaught ReferenceError: tap is not defined' in or related to this line: 'var originalScaleY = tap.scale.y;' Line Number: 238
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: 237
User prompt
добавить картинку idea в центр экрана
Code edit (1 edits merged)
Please save this source code
User prompt
Сохранять количество набранных очков
/**** * Classes ****/ // Dog class for the dog that appears when a duck crosses the bottom border var Dog = Container.expand(function () { var self = Container.call(this); var dogGraphics = self.attachAsset('dog', { anchorX: 0.5, anchorY: 0.5 }); }); // 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 += 15 * Math.cos(angle); // Move horizontally based on the angle self.y += 15 * Math.sin(angle); // Move vertically based on the angle self.scale.x -= 15 / 60 / enemyGraphics.width; // Decrease width by 20 pixels per second self.scale.y -= 15 / 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 += 1.8 * 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 = -22; 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); }; }); // XVOST class for the XVOST object that moves in a random direction at the bottom of the screen var XVOST = Container.expand(function () { var self = Container.call(this); var xvostGraphics = self.attachAsset('xvost', { anchorX: 0.5, anchorY: 1.0 }); self.speed = 2.5; self.direction = Math.PI; // Set direction to left self.update = function () { self.x += self.speed * Math.cos(self.direction); self.y = self.y; // Add code to smoothly tilt XVOST to the left and right every second if (LK.ticks % 60 < 30) { if (self.rotation > -10 * (Math.PI / 180)) { self.rotation -= 10 * (Math.PI / 180) / (0.5 * 60); // 0.5 seconds at 60FPS } } else { if (self.rotation < 10 * (Math.PI / 180)) { self.rotation += 10 * (Math.PI / 180) / (0.5 * 60); // 0.5 seconds at 60FPS } } // Mirror the XVOST object when it intersects with the game borders if (self.x < 100) { self.x = 100; self.direction = Math.PI - self.direction; // Change direction xvostGraphics.scale.x *= -1; // Mirror the XVOST object } else if (self.x > 1900) { self.x = 1900; self.direction = Math.PI - self.direction; // Change direction xvostGraphics.scale.x *= -1; // Mirror the XVOST object } if (self.y < 2000) { self.y = 2000; self.direction = -self.direction; // Change direction xvostGraphics.scale.y *= -1; // Mirror the XVOST object } else if (self.y > 2250) { self.y = 2250; self.direction = -self.direction; // Change direction xvostGraphics.scale.y *= -1; // Mirror the XVOST object } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xFFFFFF // Init game with white background }); /**** * Game Code ****/ var score = LK.getScore(); // Retrieve the current score var scoreTxt = new Text2('0', { size: 70, fill: "#000000", fontWeight: "bold" // Make the text bolder }); scoreTxt.anchor.set(1, 0); // Anchor to the top right LK.gui.topRight.addChild(scoreTxt); // 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 = 190; // 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 - 170) + 170; // 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 >= 65 || 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, rotation: -30 * (Math.PI / 180) // Rotate 30 degrees counter-clockwise }); weapon.x = 1024; // Center horizontally weapon.y = 2900; // Bottom of the screen // Add 'Napr' image to the center of the screen and handle tap logic var naprTapCount = 0; var naprLastTapTime = 0; var napr = game.addChild(new Container()); var naprGraphics = napr.attachAsset('Napr', { anchorX: 0.5, anchorY: 0.5 }); napr.x = 1700; // Center horizontally napr.y = 2150; // Center vertically napr.rotation = 7 * (Math.PI / 180); // Rotate the image by 10 degrees napr.down = function (x, y, obj) { var currentTime = LK.ticks; if (currentTime - naprLastTapTime <= 120) { // 2 seconds at 60FPS naprTapCount++; if (naprTapCount >= 5) { // Show central image for 3 seconds var centralImage = game.addChild(new Container()); var centralImageGraphics = centralImage.attachAsset('picture', { anchorX: 0.5, anchorY: 0.5 }); centralImage.x = 1024; // Center horizontally centralImage.y = 200; // Center vertically LK.setTimeout(function () { centralImage.visible = false; centralImage.destroy(); }, 3000); naprTapCount = 0; // Reset tap count } } else { naprTapCount = 1; // Reset tap count if more than 2 seconds pass } naprLastTapTime = currentTime; }; // 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(); }, 1650); // Add an XVOST object to the game var xvost = game.addChild(new XVOST()); xvost.x = Math.random() * (1800 - 200) + 200; // Randomize x position between 200 and 1800 xvost.y = 2732 - xvost.height / 2; // Position at the bottom of the screen // 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].x > 2130 && !enemies[j].hit) { LK.showGameOver(); } else 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) { // If the enemy crosses the bottom border, add a dog at its position if (enemies[j].y > 2300) { var enemyX = enemies[j].x; var enemyY = enemies[j].y; LK.setTimeout(function () { var dog = new Dog(); dog.x = enemyX; dog.y = enemyY; game.addChild(dog); // Remove the dog after 2 seconds LK.setTimeout(function () { dog.visible = false; dog.destroy(); }, 1000); }, 800); } 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, destroy the bullet on collision, and handle XVOST visibility bullet.destroy(); playerBullets.splice(b, 1); enemy.hit = true; LK.setScore(LK.getScore() + 1); // Increment score by 1 scoreTxt.setText(LK.getScore().toString()); // Update score display LK.setTimeout(function () { xvost.visible = false; // Hide XVOST 1 second after collision }, 1200); if (!xvost.visible) { LK.clearTimeout(xvostVisibilityTimer); // Clear existing timer if XVOST is currently invisible } xvostVisibilityTimer = LK.setTimeout(function () { xvost.visible = true; // Reappear XVOST after 5 seconds }, 4000); break; // Exit loop after collision to avoid errors } } } } // Update the position of the XVOST object xvost.update(); // Spawn enemies if (enemySpawnTimer <= 0) { spawnEnemy(); enemySpawnTimer = spawnEnemyInterval; } else { enemySpawnTimer--; } });
===================================================================
--- original.js
+++ change.js
@@ -165,12 +165,13 @@
// 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
+ anchorY: 0.5,
+ rotation: -30 * (Math.PI / 180) // Rotate 30 degrees counter-clockwise
});
weapon.x = 1024; // Center horizontally
-weapon.y = 2700; // Bottom of the screen
+weapon.y = 2900; // Bottom of the screen
// Add 'Napr' image to the center of the screen and handle tap logic
var naprTapCount = 0;
var naprLastTapTime = 0;
var napr = game.addChild(new Container());
черный шар. 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.