User prompt
itler olmasın
User prompt
npcler yakalanırsa -1 olsun puan
User prompt
köpek balığı belirli bölgelerde çıksın ve npcleri kovalasın
User prompt
itler belirli bölgelerde çıksın
User prompt
itler sola ve sağa gitsin
User prompt
npc kurtarilmadığında 5 numaralı efekt gelsin
User prompt
oyun başlayınca 6 numaralı müzik çalsın
User prompt
npcleri hareket etirelim
User prompt
güvenli böleyi hareket ettirelim ve adaya ulaşınca 5 adlı ses efkti duyulsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Can Kurtaran: Kurtarma Operasyonu
Initial prompt
bizim can kurtaran olup diğer oyuncuları kurtardığımız oyun
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Class for NPCs (people to rescue) var NPC = Container.expand(function () { var self = Container.call(this); // Attach NPC asset (ellipse, random color) var npcColor = 0x3498db + Math.floor(Math.random() * 0x222222); var npcAsset = self.attachAsset('npc', { width: 120, height: 120, color: npcColor, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5 }); // Is this NPC being dragged? self.isDragging = false; // Mark if rescued (to avoid double rescue) self.rescued = false; // For drag offset self.dragOffsetX = 0; self.dragOffsetY = 0; // Called every tick self.update = function () { // If not being dragged, move down and also move horizontally if (!self.isDragging && !self.rescued) { // Move down self.y += self.fallSpeed; // Move horizontally if (typeof self.dir === "undefined") { // Randomly pick initial direction: -1 (left) or 1 (right) self.dir = Math.random() < 0.5 ? -1 : 1; } if (typeof self.horizSpeed === "undefined") { // Random horizontal speed between 1.2 and 2.5 self.horizSpeed = 1.2 + Math.random() * 1.3; } self.x += self.dir * self.horizSpeed; // Bounce off screen edges var margin = 70; if (self.x < margin) { self.x = margin; self.dir = 1; } if (self.x > 2048 - margin) { self.x = 2048 - margin; self.dir = -1; } } }; // On down (touch/click) self.down = function (x, y, obj) { if (self.rescued) return; self.isDragging = true; // Calculate offset between touch and center self.dragOffsetX = self.x - x; self.dragOffsetY = self.y - y; // Bring to front if (self.parent) { self.parent.setChildIndex(self, self.parent.children.length - 1); } }; // On up (touch/click release) self.up = function (x, y, obj) { self.isDragging = false; }; return self; }); // Class for Safe Zone var SafeZone = Container.expand(function () { var self = Container.call(this); // Attach safe zone asset (green ellipse) var safeAsset = self.attachAsset('safezone', { width: 400, height: 180, color: 0x2ecc40, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5 }); // Add a label var label = new Text2('GÜVENLİ ALAN', { size: 60, fill: 0xFFFFFF }); label.anchor.set(0.5, 0.5); label.y = 0; self.addChild(label); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb // Sky blue }); /**** * Game Code ****/ // Tween plugin for animations // Game variables var npcs = []; // All NPCs on screen var safeZone; // The safe zone object var score = 0; var scoreTxt; var spawnInterval = 180; // Initial spawn interval (frames) var npcFallSpeed = 2.5; // Initial NPC fall speed var minSpawnInterval = 60; // Minimum interval (hardest) var maxNPCs = 3; // Max NPCs on screen at once (increases with difficulty) var dragNode = null; // Currently dragged NPC var lastMoveX = 0, lastMoveY = 0; // Add Safe Zone at bottom center safeZone = new SafeZone(); safeZone.x = 2048 / 2; safeZone.y = 2732 - 200; safeZone.isDragging = false; safeZone.dragOffsetX = 0; safeZone.lastX = safeZone.x; game.addChild(safeZone); // Play music '6' at game start LK.playMusic('6'); // Score text at top center scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Helper: Spawn a new NPC at random X, near top function spawnNPC() { if (npcs.length >= maxNPCs) return; var npc = new NPC(); // Random X, avoid edges var margin = 140; npc.x = margin + Math.random() * (2048 - 2 * margin); npc.y = 200 + Math.random() * 200; npc.fallSpeed = npcFallSpeed + Math.random() * 1.5; npc.isDragging = false; npc.rescued = false; npc.lastIntersecting = false; npcs.push(npc); game.addChild(npc); } // Helper: Remove NPC from game and array function removeNPC(npc) { var idx = npcs.indexOf(npc); if (idx !== -1) { npcs.splice(idx, 1); } npc.destroy(); } // Helper: Rescue NPC (with animation) function rescueNPC(npc) { npc.rescued = true; // Animate: scale up and fade out tween(npc, { scaleX: 1.5, scaleY: 1.5, alpha: 0 }, { duration: 400, easing: tween.easeOut, onFinish: function onFinish() { removeNPC(npc); } }); // Score up score += 1; LK.setScore(score); scoreTxt.setText(score); // Difficulty increases every 5 points if (score % 5 === 0 && spawnInterval > minSpawnInterval) { spawnInterval -= 15; npcFallSpeed += 0.5; maxNPCs = Math.min(6, maxNPCs + 1); // Flash safe zone to indicate difficulty up LK.effects.flashObject(safeZone, 0xffff00, 400); } } // Helper: Game over (NPC fell below screen) function triggerGameOver() { LK.effects.flashScreen(0xff0000, 800); LK.showGameOver(); } // Game move handler (drag NPCs) function handleMove(x, y, obj) { lastMoveX = x; lastMoveY = y; if (dragNode && !dragNode.rescued) { dragNode.x = x + dragNode.dragOffsetX; dragNode.y = y + dragNode.dragOffsetY; } // Safe zone dragging (horizontal only) if (safeZone.isDragging) { // Only allow horizontal movement, keep y fixed var newX = x + safeZone.dragOffsetX; // Clamp within screen var minX = safeZone.width / 2; var maxX = 2048 - safeZone.width / 2; if (newX < minX) newX = minX; if (newX > maxX) newX = maxX; safeZone.x = newX; } } game.move = handleMove; // On down: check if touching an NPC or safe zone game.down = function (x, y, obj) { // Find topmost NPC under pointer var found = false; for (var i = npcs.length - 1; i >= 0; i--) { var npc = npcs[i]; // Simple hit test (circle) var dx = x - npc.x; var dy = y - npc.y; var r = 60; if (dx * dx + dy * dy < r * r && !npc.rescued) { dragNode = npc; npc.down(x, y, obj); found = true; break; } } // If not on NPC, check if on safe zone (ellipse hit test) if (!found) { var dxz = x - safeZone.x; var dyz = y - safeZone.y; // Ellipse: (dx/a)^2 + (dy/b)^2 <= 1 var a = safeZone.width / 2; var b = safeZone.height / 2; if (dxz * dxz / (a * a) + dyz * dyz / (b * b) <= 1) { safeZone.isDragging = true; safeZone.dragOffsetX = safeZone.x - x; } } }; // On up: release drag game.up = function (x, y, obj) { if (dragNode) { dragNode.up(x, y, obj); dragNode = null; } if (safeZone.isDragging) { safeZone.isDragging = false; } }; // Main game update loop game.update = function () { // Spawn NPCs at interval if (LK.ticks % spawnInterval === 0) { spawnNPC(); } // Update all NPCs for (var i = npcs.length - 1; i >= 0; i--) { var npc = npcs[i]; // If being dragged, follow finger (handled in move) // If not, update position (handled in class update) // Check if rescued (intersecting safe zone) var isIntersecting = !npc.rescued && npc.intersects(safeZone); if (!npc.lastIntersecting && isIntersecting) { rescueNPC(npc); } npc.lastIntersecting = isIntersecting; // If NPC falls below screen, play sound and game over if (!npc.rescued && npc.y > 2732 + 80) { LK.getSound('5').play(); triggerGameOver(); return; } } // --- Safe zone left edge detection and sound effect --- if (typeof safeZone.lastX === "undefined") safeZone.lastX = safeZone.x; var leftEdge = safeZone.width / 2; if (safeZone.lastX > leftEdge && safeZone.x <= leftEdge) { // Play sound '5' when safe zone reaches the left edge LK.getSound('5').play(); } safeZone.lastX = safeZone.x; }; // Initial spawn for (var i = 0; i < 2; i++) { spawnNPC(); } score = 0; LK.setScore(score); scoreTxt.setText(score);
===================================================================
--- original.js
+++ change.js
@@ -268,10 +268,11 @@
if (!npc.lastIntersecting && isIntersecting) {
rescueNPC(npc);
}
npc.lastIntersecting = isIntersecting;
- // If NPC falls below screen, game over
+ // If NPC falls below screen, play sound and game over
if (!npc.rescued && npc.y > 2732 + 80) {
+ LK.getSound('5').play();
triggerGameOver();
return;
}
}