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, slowly move down (simulate danger) if (!self.isDragging && !self.rescued) { self.y += self.fallSpeed; } }; // 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; game.addChild(safeZone); // 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; } } game.move = handleMove; // On down: check if touching an NPC game.down = function (x, y, obj) { // Find topmost NPC under pointer 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); break; } } // If not on NPC, no drag }; // On up: release drag game.up = function (x, y, obj) { if (dragNode) { dragNode.up(x, y, obj); dragNode = null; } }; // 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, game over if (!npc.rescued && npc.y > 2732 + 80) { triggerGameOver(); return; } } }; // Initial spawn for (var i = 0; i < 2; i++) { spawnNPC(); } score = 0; LK.setScore(score); scoreTxt.setText(score);
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,232 @@
-/****
+/****
+* 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, slowly move down (simulate danger)
+ if (!self.isDragging && !self.rescued) {
+ self.y += self.fallSpeed;
+ }
+ };
+ // 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: 0x000000
-});
\ No newline at end of file
+ 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;
+game.addChild(safeZone);
+// 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;
+ }
+}
+game.move = handleMove;
+// On down: check if touching an NPC
+game.down = function (x, y, obj) {
+ // Find topmost NPC under pointer
+ 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);
+ break;
+ }
+ }
+ // If not on NPC, no drag
+};
+// On up: release drag
+game.up = function (x, y, obj) {
+ if (dragNode) {
+ dragNode.up(x, y, obj);
+ dragNode = null;
+ }
+};
+// 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, game over
+ if (!npc.rescued && npc.y > 2732 + 80) {
+ triggerGameOver();
+ return;
+ }
+ }
+};
+// Initial spawn
+for (var i = 0; i < 2; i++) {
+ spawnNPC();
+}
+score = 0;
+LK.setScore(score);
+scoreTxt.setText(score);
\ No newline at end of file