User prompt
Kapıyı açınca 2 odaya geçelim
User prompt
Kutuya iki kere tıklayınca açılsın
User prompt
Levye kapının yanında olsun
User prompt
Kapı 3 anahtarı yerine koyunca açılsın
User prompt
Suya tıklayınca 2 anahtar çıksın
User prompt
Birazcık daha zor olsun
User prompt
Oyunu Türkçe yazılar ekle
Code edit (1 edits merged)
Please save this source code
User prompt
Time Loop Escape Room
Initial prompt
Zamanda Sıkışmış Kaçış Odası (Escape Room) Konu: Her başarısızlıkta zaman geri sarılıyor ama ortam değişiyor. İnteraktif objeler, hafif hikâye anlatımı ve fizik bulmacaları ekleyebilirsin.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Door = Container.expand(function (x, y) { var self = Container.call(this); var graphics = self.attachAsset('door', { anchorX: 0.5, anchorY: 0.5 }); self.x = x; self.y = y; self.isLocked = true; self.tryOpen = function () { if (self.isLocked) { showMessage("The door is locked. You need a key!"); return false; } else { showMessage("The door opens! You escaped!"); LK.getSound('success').play(); return true; } }; self.unlock = function () { self.isLocked = false; graphics.tint = 0x00ff00; LK.effects.flashObject(self, 0xffffff, 1000); showMessage("Door unlocked!"); }; self.down = function (x, y, obj) { if (self.tryOpen()) { victory(); } }; return self; }); var InteractiveObject = Container.expand(function (type, x, y, data) { var self = Container.call(this); self.objectType = type; self.objectData = data || {}; self.isExamined = false; self.isUsed = false; var graphics = self.attachAsset(type, { anchorX: 0.5, anchorY: 0.5 }); self.x = x; self.y = y; self.examine = function () { self.isExamined = true; LK.effects.flashObject(self, 0xffffff, 500); LK.getSound('click').play(); if (self.objectType === 'note') { showMessage("The note reads: '" + self.objectData.text + "'"); } else if (self.objectType === 'key') { showMessage("A golden key. It might unlock something..."); } else if (self.objectType === 'box') { showMessage("A wooden box. It feels heavy."); } else if (self.objectType === 'button') { showMessage("A red button. Wonder what it does?"); } else if (self.objectType === 'lever') { showMessage("A metal lever. It can be pulled."); } }; self.use = function () { if (self.objectType === 'button') { self.isUsed = !self.isUsed; graphics.tint = self.isUsed ? 0x00ff00 : 0xff4444; LK.getSound('click').play(); showMessage(self.isUsed ? "Button activated!" : "Button deactivated!"); } else if (self.objectType === 'lever') { self.isUsed = !self.isUsed; graphics.rotation = self.isUsed ? Math.PI / 4 : 0; LK.getSound('click').play(); showMessage(self.isUsed ? "Lever pulled!" : "Lever reset!"); } }; self.down = function (x, y, obj) { if (self.objectType === 'key') { draggedObject = self; } else { self.examine(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ var currentLoop = storage.currentLoop || 0; var timeLimit = 60000; // 60 seconds var startTime = 0; var gameObjects = []; var draggedObject = null; var door = null; var messageText = null; var timerText = null; var loopText = null; var isGameActive = true; // UI Setup var titleText = new Text2('Time Loop Escape Room', { size: 80, fill: '#ffffff' }); titleText.anchor.set(0.5, 0); LK.gui.top.addChild(titleText); timerText = new Text2('Time: 60s', { size: 60, fill: '#ffff00' }); timerText.anchor.set(1, 0); LK.gui.topRight.addChild(timerText); loopText = new Text2('Loop: ' + (currentLoop + 1), { size: 50, fill: '#00ffff' }); loopText.anchor.set(0, 0); loopText.x = 120; LK.gui.topLeft.addChild(loopText); messageText = new Text2('', { size: 50, fill: '#ffffff' }); messageText.anchor.set(0.5, 1); LK.gui.bottom.addChild(messageText); function showMessage(text) { messageText.setText(text); messageText.alpha = 1; tween(messageText, { alpha: 0 }, { duration: 3000 }); } function initializeRoom() { // Clear existing objects for (var i = gameObjects.length - 1; i >= 0; i--) { gameObjects[i].destroy(); } gameObjects = []; // Create door door = new Door(2048 - 200, 2732 / 2); game.addChild(door); // Create objects based on loop number var keyX = 300 + currentLoop * 50 % 400; var keyY = 2000 + currentLoop * 30 % 200; var key = new InteractiveObject('key', keyX, keyY); gameObjects.push(key); game.addChild(key); // Box position changes each loop var boxX = 500 + currentLoop * 100 % 600; var boxY = 1500 + currentLoop * 80 % 400; var box = new InteractiveObject('box', boxX, boxY, { containsKey: currentLoop > 0 }); gameObjects.push(box); game.addChild(box); // Button appears after first loop if (currentLoop > 0) { var button = new InteractiveObject('button', 1500, 1800); gameObjects.push(button); game.addChild(button); } // Lever appears after second loop if (currentLoop > 1) { var lever = new InteractiveObject('lever', 1200, 1600); gameObjects.push(lever); game.addChild(lever); } // Note with different text each loop var noteTexts = ["The key opens the door...", "The box hides secrets...", "Buttons and levers control the room...", "Everything is connected..."]; var note = new InteractiveObject('note', 800, 1200, { text: noteTexts[Math.min(currentLoop, noteTexts.length - 1)] }); gameObjects.push(note); game.addChild(note); startTime = Date.now(); isGameActive = true; showMessage("Loop " + (currentLoop + 1) + " - Find a way to escape!"); } function resetLoop() { currentLoop++; storage.currentLoop = currentLoop; LK.getSound('reset').play(); LK.effects.flashScreen(0xff0000, 1000); loopText.setText('Loop: ' + (currentLoop + 1)); // Reset after a short delay LK.setTimeout(function () { initializeRoom(); }, 1000); } function victory() { isGameActive = false; showMessage("Congratulations! You escaped in " + (currentLoop + 1) + " loops!"); // Reset progress storage.currentLoop = 0; currentLoop = 0; LK.setTimeout(function () { LK.showYouWin(); }, 2000); } function checkPuzzleCompletion() { // Simple puzzle: need key to unlock door // More complex puzzles added in later loops if (currentLoop === 0) { // First loop: just need key return true; } else if (currentLoop === 1) { // Second loop: need button pressed for (var i = 0; i < gameObjects.length; i++) { if (gameObjects[i].objectType === 'button' && gameObjects[i].isUsed) { return true; } } return false; } else { // Later loops: need button and lever var buttonPressed = false; var leverPulled = false; for (var i = 0; i < gameObjects.length; i++) { if (gameObjects[i].objectType === 'button' && gameObjects[i].isUsed) { buttonPressed = true; } if (gameObjects[i].objectType === 'lever' && gameObjects[i].isUsed) { leverPulled = true; } } return buttonPressed && leverPulled; } } game.move = function (x, y, obj) { if (draggedObject) { draggedObject.x = x; draggedObject.y = y; // Check if key is dropped on door if (draggedObject.objectType === 'key' && door.intersects(draggedObject)) { if (checkPuzzleCompletion()) { door.unlock(); draggedObject.destroy(); draggedObject = null; // Remove key from gameObjects array for (var i = 0; i < gameObjects.length; i++) { if (gameObjects[i] === draggedObject) { gameObjects.splice(i, 1); break; } } } else { showMessage("Something else needs to be done first..."); } } } }; game.up = function (x, y, obj) { draggedObject = null; }; game.down = function (x, y, obj) { // Handle clicking on objects for (var i = 0; i < gameObjects.length; i++) { if (gameObjects[i].objectType === 'button' || gameObjects[i].objectType === 'lever') { var objPos = gameObjects[i].toGlobal({ x: 0, y: 0 }); var gamePos = game.toLocal(objPos); var distance = Math.sqrt(Math.pow(x - gamePos.x, 2) + Math.pow(y - gamePos.y, 2)); if (distance < 100) { gameObjects[i].use(); break; } } } }; game.update = function () { if (!isGameActive) return; var currentTime = Date.now(); var elapsed = currentTime - startTime; var remaining = Math.max(0, timeLimit - elapsed); timerText.setText('Time: ' + Math.ceil(remaining / 1000) + 's'); if (remaining <= 0) { isGameActive = false; showMessage("Time's up! The room resets..."); LK.setTimeout(function () { resetLoop(); }, 2000); } }; // Initialize first room initializeRoom();
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,302 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var Door = Container.expand(function (x, y) {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('door', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.x = x;
+ self.y = y;
+ self.isLocked = true;
+ self.tryOpen = function () {
+ if (self.isLocked) {
+ showMessage("The door is locked. You need a key!");
+ return false;
+ } else {
+ showMessage("The door opens! You escaped!");
+ LK.getSound('success').play();
+ return true;
+ }
+ };
+ self.unlock = function () {
+ self.isLocked = false;
+ graphics.tint = 0x00ff00;
+ LK.effects.flashObject(self, 0xffffff, 1000);
+ showMessage("Door unlocked!");
+ };
+ self.down = function (x, y, obj) {
+ if (self.tryOpen()) {
+ victory();
+ }
+ };
+ return self;
+});
+var InteractiveObject = Container.expand(function (type, x, y, data) {
+ var self = Container.call(this);
+ self.objectType = type;
+ self.objectData = data || {};
+ self.isExamined = false;
+ self.isUsed = false;
+ var graphics = self.attachAsset(type, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.x = x;
+ self.y = y;
+ self.examine = function () {
+ self.isExamined = true;
+ LK.effects.flashObject(self, 0xffffff, 500);
+ LK.getSound('click').play();
+ if (self.objectType === 'note') {
+ showMessage("The note reads: '" + self.objectData.text + "'");
+ } else if (self.objectType === 'key') {
+ showMessage("A golden key. It might unlock something...");
+ } else if (self.objectType === 'box') {
+ showMessage("A wooden box. It feels heavy.");
+ } else if (self.objectType === 'button') {
+ showMessage("A red button. Wonder what it does?");
+ } else if (self.objectType === 'lever') {
+ showMessage("A metal lever. It can be pulled.");
+ }
+ };
+ self.use = function () {
+ if (self.objectType === 'button') {
+ self.isUsed = !self.isUsed;
+ graphics.tint = self.isUsed ? 0x00ff00 : 0xff4444;
+ LK.getSound('click').play();
+ showMessage(self.isUsed ? "Button activated!" : "Button deactivated!");
+ } else if (self.objectType === 'lever') {
+ self.isUsed = !self.isUsed;
+ graphics.rotation = self.isUsed ? Math.PI / 4 : 0;
+ LK.getSound('click').play();
+ showMessage(self.isUsed ? "Lever pulled!" : "Lever reset!");
+ }
+ };
+ self.down = function (x, y, obj) {
+ if (self.objectType === 'key') {
+ draggedObject = self;
+ } else {
+ self.examine();
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x1a1a1a
+});
+
+/****
+* Game Code
+****/
+var currentLoop = storage.currentLoop || 0;
+var timeLimit = 60000; // 60 seconds
+var startTime = 0;
+var gameObjects = [];
+var draggedObject = null;
+var door = null;
+var messageText = null;
+var timerText = null;
+var loopText = null;
+var isGameActive = true;
+// UI Setup
+var titleText = new Text2('Time Loop Escape Room', {
+ size: 80,
+ fill: '#ffffff'
+});
+titleText.anchor.set(0.5, 0);
+LK.gui.top.addChild(titleText);
+timerText = new Text2('Time: 60s', {
+ size: 60,
+ fill: '#ffff00'
+});
+timerText.anchor.set(1, 0);
+LK.gui.topRight.addChild(timerText);
+loopText = new Text2('Loop: ' + (currentLoop + 1), {
+ size: 50,
+ fill: '#00ffff'
+});
+loopText.anchor.set(0, 0);
+loopText.x = 120;
+LK.gui.topLeft.addChild(loopText);
+messageText = new Text2('', {
+ size: 50,
+ fill: '#ffffff'
+});
+messageText.anchor.set(0.5, 1);
+LK.gui.bottom.addChild(messageText);
+function showMessage(text) {
+ messageText.setText(text);
+ messageText.alpha = 1;
+ tween(messageText, {
+ alpha: 0
+ }, {
+ duration: 3000
+ });
+}
+function initializeRoom() {
+ // Clear existing objects
+ for (var i = gameObjects.length - 1; i >= 0; i--) {
+ gameObjects[i].destroy();
+ }
+ gameObjects = [];
+ // Create door
+ door = new Door(2048 - 200, 2732 / 2);
+ game.addChild(door);
+ // Create objects based on loop number
+ var keyX = 300 + currentLoop * 50 % 400;
+ var keyY = 2000 + currentLoop * 30 % 200;
+ var key = new InteractiveObject('key', keyX, keyY);
+ gameObjects.push(key);
+ game.addChild(key);
+ // Box position changes each loop
+ var boxX = 500 + currentLoop * 100 % 600;
+ var boxY = 1500 + currentLoop * 80 % 400;
+ var box = new InteractiveObject('box', boxX, boxY, {
+ containsKey: currentLoop > 0
+ });
+ gameObjects.push(box);
+ game.addChild(box);
+ // Button appears after first loop
+ if (currentLoop > 0) {
+ var button = new InteractiveObject('button', 1500, 1800);
+ gameObjects.push(button);
+ game.addChild(button);
+ }
+ // Lever appears after second loop
+ if (currentLoop > 1) {
+ var lever = new InteractiveObject('lever', 1200, 1600);
+ gameObjects.push(lever);
+ game.addChild(lever);
+ }
+ // Note with different text each loop
+ var noteTexts = ["The key opens the door...", "The box hides secrets...", "Buttons and levers control the room...", "Everything is connected..."];
+ var note = new InteractiveObject('note', 800, 1200, {
+ text: noteTexts[Math.min(currentLoop, noteTexts.length - 1)]
+ });
+ gameObjects.push(note);
+ game.addChild(note);
+ startTime = Date.now();
+ isGameActive = true;
+ showMessage("Loop " + (currentLoop + 1) + " - Find a way to escape!");
+}
+function resetLoop() {
+ currentLoop++;
+ storage.currentLoop = currentLoop;
+ LK.getSound('reset').play();
+ LK.effects.flashScreen(0xff0000, 1000);
+ loopText.setText('Loop: ' + (currentLoop + 1));
+ // Reset after a short delay
+ LK.setTimeout(function () {
+ initializeRoom();
+ }, 1000);
+}
+function victory() {
+ isGameActive = false;
+ showMessage("Congratulations! You escaped in " + (currentLoop + 1) + " loops!");
+ // Reset progress
+ storage.currentLoop = 0;
+ currentLoop = 0;
+ LK.setTimeout(function () {
+ LK.showYouWin();
+ }, 2000);
+}
+function checkPuzzleCompletion() {
+ // Simple puzzle: need key to unlock door
+ // More complex puzzles added in later loops
+ if (currentLoop === 0) {
+ // First loop: just need key
+ return true;
+ } else if (currentLoop === 1) {
+ // Second loop: need button pressed
+ for (var i = 0; i < gameObjects.length; i++) {
+ if (gameObjects[i].objectType === 'button' && gameObjects[i].isUsed) {
+ return true;
+ }
+ }
+ return false;
+ } else {
+ // Later loops: need button and lever
+ var buttonPressed = false;
+ var leverPulled = false;
+ for (var i = 0; i < gameObjects.length; i++) {
+ if (gameObjects[i].objectType === 'button' && gameObjects[i].isUsed) {
+ buttonPressed = true;
+ }
+ if (gameObjects[i].objectType === 'lever' && gameObjects[i].isUsed) {
+ leverPulled = true;
+ }
+ }
+ return buttonPressed && leverPulled;
+ }
+}
+game.move = function (x, y, obj) {
+ if (draggedObject) {
+ draggedObject.x = x;
+ draggedObject.y = y;
+ // Check if key is dropped on door
+ if (draggedObject.objectType === 'key' && door.intersects(draggedObject)) {
+ if (checkPuzzleCompletion()) {
+ door.unlock();
+ draggedObject.destroy();
+ draggedObject = null;
+ // Remove key from gameObjects array
+ for (var i = 0; i < gameObjects.length; i++) {
+ if (gameObjects[i] === draggedObject) {
+ gameObjects.splice(i, 1);
+ break;
+ }
+ }
+ } else {
+ showMessage("Something else needs to be done first...");
+ }
+ }
+ }
+};
+game.up = function (x, y, obj) {
+ draggedObject = null;
+};
+game.down = function (x, y, obj) {
+ // Handle clicking on objects
+ for (var i = 0; i < gameObjects.length; i++) {
+ if (gameObjects[i].objectType === 'button' || gameObjects[i].objectType === 'lever') {
+ var objPos = gameObjects[i].toGlobal({
+ x: 0,
+ y: 0
+ });
+ var gamePos = game.toLocal(objPos);
+ var distance = Math.sqrt(Math.pow(x - gamePos.x, 2) + Math.pow(y - gamePos.y, 2));
+ if (distance < 100) {
+ gameObjects[i].use();
+ break;
+ }
+ }
+ }
+};
+game.update = function () {
+ if (!isGameActive) return;
+ var currentTime = Date.now();
+ var elapsed = currentTime - startTime;
+ var remaining = Math.max(0, timeLimit - elapsed);
+ timerText.setText('Time: ' + Math.ceil(remaining / 1000) + 's');
+ if (remaining <= 0) {
+ isGameActive = false;
+ showMessage("Time's up! The room resets...");
+ LK.setTimeout(function () {
+ resetLoop();
+ }, 2000);
+ }
+};
+// Initialize first room
+initializeRoom();
\ No newline at end of file