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 CombinationLock = Container.expand(function (x, y, correctSeq) { var self = Container.call(this); self.correctSequence = correctSeq; self.currentSequence = []; self.maxLength = 4; var graphics = self.attachAsset('button', { anchorX: 0.5, anchorY: 0.5 }); graphics.tint = 0x4444ff; self.x = x; self.y = y; self.addToSequence = function (value) { self.currentSequence.push(value); if (self.currentSequence.length > self.maxLength) { self.currentSequence.shift(); } showMessage("Kombinasyon: " + self.currentSequence.join('-')); }; self.checkSequence = function () { if (self.currentSequence.length === self.correctSequence.length) { for (var i = 0; i < self.currentSequence.length; i++) { if (self.currentSequence[i] !== self.correctSequence[i]) { return false; } } return true; } return false; }; self.reset = function () { self.currentSequence = []; }; self.down = function (x, y, obj) { self.addToSequence(1); }; return self; }); 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("Kapı kilitli. Bir anahtara ihtiyacınız var!"); return false; } else { showMessage("Kapı açılıyor! Kaçtınız!"); LK.getSound('success').play(); return true; } }; self.unlock = function () { self.isLocked = false; graphics.tint = 0x00ff00; LK.effects.flashObject(self, 0xffffff, 1000); showMessage("Kapı kilidi açıldı!"); }; 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; self.requiredSequence = data ? data.requiredSequence : null; 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("Notta yazıyor: '" + self.objectData.text + "'"); } else if (self.objectType === 'key') { showMessage("Altın bir anahtar. Bir şeyleri açabilir..."); } else if (self.objectType === 'box') { if (self.objectData.isLocked && currentLoop > 2) { showMessage("Kutu kilitli. Doğru sırayla düğmelere basın!"); } else { showMessage("Ahşap bir kutu. Ağır hissediliyor."); } } else if (self.objectType === 'button') { showMessage("Renkli bir düğme. Sırası önemli olabilir..."); } else if (self.objectType === 'lever') { showMessage("Metal bir kol. Çekilebilir."); } }; self.use = function () { if (self.objectType === 'button') { // Add penalty for wrong sequence if (self.requiredSequence && combination.length === 0) { combination.push(self.objectData.buttonId); } else if (self.requiredSequence && combination.length < self.requiredSequence.length) { combination.push(self.objectData.buttonId); if (combination[combination.length - 1] !== self.requiredSequence[combination.length - 1]) { penalties++; startTime -= wrongActionPenalty; showMessage("Yanlış sıra! " + wrongActionPenalty / 1000 + " saniye ceza!"); LK.effects.flashScreen(0xff0000, 500); combination = []; } } self.isUsed = !self.isUsed; graphics.tint = self.isUsed ? 0x00ff00 : 0xff4444; LK.getSound('click').play(); showMessage(self.isUsed ? "Düğme etkinleştirildi!" : "Düğme devre dışı!"); } else if (self.objectType === 'lever') { self.isUsed = !self.isUsed; graphics.rotation = self.isUsed ? Math.PI / 4 : 0; LK.getSound('click').play(); showMessage(self.isUsed ? "Kol çekildi!" : "Kol sıfırlandı!"); } }; 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 baseTimeLimit = 60000; // 60 seconds var timeLimit = Math.max(30000, baseTimeLimit - currentLoop * 5000); // Reduce by 5s each loop, minimum 30s var startTime = 0; var gameObjects = []; var draggedObject = null; var door = null; var messageText = null; var timerText = null; var loopText = null; var isGameActive = true; var combination = []; var correctCombination = []; var wrongActionPenalty = 5000; // 5 second penalty var penalties = 0; // UI Setup var titleText = new Text2('Zamanda Sıkışmış Kaçış Odası', { size: 80, fill: '#ffffff' }); titleText.anchor.set(0.5, 0); LK.gui.top.addChild(titleText); timerText = new Text2('Süre: 60s', { size: 60, fill: '#ffff00' }); timerText.anchor.set(1, 0); LK.gui.topRight.addChild(timerText); loopText = new Text2('Döngü: ' + (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, { buttonId: 1 }); 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); } // Multiple buttons with combination system (loop 3+) if (currentLoop > 2) { correctCombination = [1, 3, 2, 4]; // Correct sequence combination = []; // Reset combination var buttonPositions = [{ x: 1400, y: 1600 }, { x: 1600, y: 1600 }, { x: 1400, y: 1800 }, { x: 1600, y: 1800 }]; for (var b = 0; b < 4; b++) { var colorButton = new InteractiveObject('button', buttonPositions[b].x, buttonPositions[b].y, { buttonId: b + 1, requiredSequence: correctCombination }); var graphics = colorButton.children[0]; var colors = [0xff4444, 0x44ff44, 0x4444ff, 0xffff44]; graphics.tint = colors[b]; gameObjects.push(colorButton); game.addChild(colorButton); } } // Note with different text each loop var noteTexts = ["Anahtar kapıyı açar...", "Kutu sırları gizliyor...", "Düğmeler ve kollar odayı kontrol ediyor...", "Sıra önemli: Kırmızı, Mavi, Yeşil, Sarı...", "Her hata zaman kaybettirir..."]; 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("Döngü " + (currentLoop + 1) + " - Kaçış yolu bulun!"); } function resetLoop() { currentLoop++; storage.currentLoop = currentLoop; timeLimit = Math.max(30000, baseTimeLimit - currentLoop * 5000); // Update time limit combination = []; penalties = 0; LK.getSound('reset').play(); LK.effects.flashScreen(0xff0000, 1000); loopText.setText('Döngü: ' + (currentLoop + 1)); // Reset after a short delay LK.setTimeout(function () { initializeRoom(); }, 1000); } function victory() { isGameActive = false; showMessage("Tebrikler! " + (currentLoop + 1) + " döngüde kaçtınız!"); // Reset progress storage.currentLoop = 0; currentLoop = 0; LK.setTimeout(function () { LK.showYouWin(); }, 2000); } function checkPuzzleCompletion() { // Progressive difficulty system 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 if (currentLoop === 2) { // Third loop: 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; } else { // Later loops: need correct button combination if (combination.length === correctCombination.length) { for (var i = 0; i < combination.length; i++) { if (combination[i] !== correctCombination[i]) { return false; } } return true; } return false; } } 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("Önce başka bir şey yapılması gerekiyor..."); } } } }; 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); var timerDisplay = 'Süre: ' + Math.ceil(remaining / 1000) + 's'; if (penalties > 0) { timerDisplay += ' (Ceza: ' + penalties + ')'; } timerText.setText(timerDisplay); if (remaining <= 0) { isGameActive = false; showMessage("Süre doldu! Oda sıfırlanıyor..."); LK.setTimeout(function () { resetLoop(); }, 2000); } }; // Initialize first room initializeRoom();
===================================================================
--- original.js
+++ change.js
@@ -6,8 +6,46 @@
/****
* Classes
****/
+var CombinationLock = Container.expand(function (x, y, correctSeq) {
+ var self = Container.call(this);
+ self.correctSequence = correctSeq;
+ self.currentSequence = [];
+ self.maxLength = 4;
+ var graphics = self.attachAsset('button', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ graphics.tint = 0x4444ff;
+ self.x = x;
+ self.y = y;
+ self.addToSequence = function (value) {
+ self.currentSequence.push(value);
+ if (self.currentSequence.length > self.maxLength) {
+ self.currentSequence.shift();
+ }
+ showMessage("Kombinasyon: " + self.currentSequence.join('-'));
+ };
+ self.checkSequence = function () {
+ if (self.currentSequence.length === self.correctSequence.length) {
+ for (var i = 0; i < self.currentSequence.length; i++) {
+ if (self.currentSequence[i] !== self.correctSequence[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ };
+ self.reset = function () {
+ self.currentSequence = [];
+ };
+ self.down = function (x, y, obj) {
+ self.addToSequence(1);
+ };
+ return self;
+});
var Door = Container.expand(function (x, y) {
var self = Container.call(this);
var graphics = self.attachAsset('door', {
anchorX: 0.5,
@@ -44,8 +82,9 @@
self.objectType = type;
self.objectData = data || {};
self.isExamined = false;
self.isUsed = false;
+ self.requiredSequence = data ? data.requiredSequence : null;
var graphics = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
@@ -59,17 +98,34 @@
showMessage("Notta yazıyor: '" + self.objectData.text + "'");
} else if (self.objectType === 'key') {
showMessage("Altın bir anahtar. Bir şeyleri açabilir...");
} else if (self.objectType === 'box') {
- showMessage("Ahşap bir kutu. Ağır hissediliyor.");
+ if (self.objectData.isLocked && currentLoop > 2) {
+ showMessage("Kutu kilitli. Doğru sırayla düğmelere basın!");
+ } else {
+ showMessage("Ahşap bir kutu. Ağır hissediliyor.");
+ }
} else if (self.objectType === 'button') {
- showMessage("Kırmızı bir düğme. Ne işe yarar acaba?");
+ showMessage("Renkli bir düğme. Sırası önemli olabilir...");
} else if (self.objectType === 'lever') {
showMessage("Metal bir kol. Çekilebilir.");
}
};
self.use = function () {
if (self.objectType === 'button') {
+ // Add penalty for wrong sequence
+ if (self.requiredSequence && combination.length === 0) {
+ combination.push(self.objectData.buttonId);
+ } else if (self.requiredSequence && combination.length < self.requiredSequence.length) {
+ combination.push(self.objectData.buttonId);
+ if (combination[combination.length - 1] !== self.requiredSequence[combination.length - 1]) {
+ penalties++;
+ startTime -= wrongActionPenalty;
+ showMessage("Yanlış sıra! " + wrongActionPenalty / 1000 + " saniye ceza!");
+ LK.effects.flashScreen(0xff0000, 500);
+ combination = [];
+ }
+ }
self.isUsed = !self.isUsed;
graphics.tint = self.isUsed ? 0x00ff00 : 0xff4444;
LK.getSound('click').play();
showMessage(self.isUsed ? "Düğme etkinleştirildi!" : "Düğme devre dışı!");
@@ -100,17 +156,22 @@
/****
* Game Code
****/
var currentLoop = storage.currentLoop || 0;
-var timeLimit = 60000; // 60 seconds
+var baseTimeLimit = 60000; // 60 seconds
+var timeLimit = Math.max(30000, baseTimeLimit - currentLoop * 5000); // Reduce by 5s each loop, minimum 30s
var startTime = 0;
var gameObjects = [];
var draggedObject = null;
var door = null;
var messageText = null;
var timerText = null;
var loopText = null;
var isGameActive = true;
+var combination = [];
+var correctCombination = [];
+var wrongActionPenalty = 5000; // 5 second penalty
+var penalties = 0;
// UI Setup
var titleText = new Text2('Zamanda Sıkışmış Kaçış Odası', {
size: 80,
fill: '#ffffff'
@@ -169,9 +230,11 @@
gameObjects.push(box);
game.addChild(box);
// Button appears after first loop
if (currentLoop > 0) {
- var button = new InteractiveObject('button', 1500, 1800);
+ var button = new InteractiveObject('button', 1500, 1800, {
+ buttonId: 1
+ });
gameObjects.push(button);
game.addChild(button);
}
// Lever appears after second loop
@@ -179,10 +242,39 @@
var lever = new InteractiveObject('lever', 1200, 1600);
gameObjects.push(lever);
game.addChild(lever);
}
+ // Multiple buttons with combination system (loop 3+)
+ if (currentLoop > 2) {
+ correctCombination = [1, 3, 2, 4]; // Correct sequence
+ combination = []; // Reset combination
+ var buttonPositions = [{
+ x: 1400,
+ y: 1600
+ }, {
+ x: 1600,
+ y: 1600
+ }, {
+ x: 1400,
+ y: 1800
+ }, {
+ x: 1600,
+ y: 1800
+ }];
+ for (var b = 0; b < 4; b++) {
+ var colorButton = new InteractiveObject('button', buttonPositions[b].x, buttonPositions[b].y, {
+ buttonId: b + 1,
+ requiredSequence: correctCombination
+ });
+ var graphics = colorButton.children[0];
+ var colors = [0xff4444, 0x44ff44, 0x4444ff, 0xffff44];
+ graphics.tint = colors[b];
+ gameObjects.push(colorButton);
+ game.addChild(colorButton);
+ }
+ }
// Note with different text each loop
- var noteTexts = ["Anahtar kapıyı açar...", "Kutu sırları gizliyor...", "Düğmeler ve kollar odayı kontrol ediyor...", "Her şey bağlantılı..."];
+ var noteTexts = ["Anahtar kapıyı açar...", "Kutu sırları gizliyor...", "Düğmeler ve kollar odayı kontrol ediyor...", "Sıra önemli: Kırmızı, Mavi, Yeşil, Sarı...", "Her hata zaman kaybettirir..."];
var note = new InteractiveObject('note', 800, 1200, {
text: noteTexts[Math.min(currentLoop, noteTexts.length - 1)]
});
gameObjects.push(note);
@@ -193,8 +285,11 @@
}
function resetLoop() {
currentLoop++;
storage.currentLoop = currentLoop;
+ timeLimit = Math.max(30000, baseTimeLimit - currentLoop * 5000); // Update time limit
+ combination = [];
+ penalties = 0;
LK.getSound('reset').play();
LK.effects.flashScreen(0xff0000, 1000);
loopText.setText('Döngü: ' + (currentLoop + 1));
// Reset after a short delay
@@ -212,10 +307,9 @@
LK.showYouWin();
}, 2000);
}
function checkPuzzleCompletion() {
- // Simple puzzle: need key to unlock door
- // More complex puzzles added in later loops
+ // Progressive difficulty system
if (currentLoop === 0) {
// First loop: just need key
return true;
} else if (currentLoop === 1) {
@@ -225,10 +319,10 @@
return true;
}
}
return false;
- } else {
- // Later loops: need button and lever
+ } else if (currentLoop === 2) {
+ // Third loop: 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) {
@@ -238,8 +332,19 @@
leverPulled = true;
}
}
return buttonPressed && leverPulled;
+ } else {
+ // Later loops: need correct button combination
+ if (combination.length === correctCombination.length) {
+ for (var i = 0; i < combination.length; i++) {
+ if (combination[i] !== correctCombination[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
}
}
game.move = function (x, y, obj) {
if (draggedObject) {
@@ -288,9 +393,13 @@
if (!isGameActive) return;
var currentTime = Date.now();
var elapsed = currentTime - startTime;
var remaining = Math.max(0, timeLimit - elapsed);
- timerText.setText('Süre: ' + Math.ceil(remaining / 1000) + 's');
+ var timerDisplay = 'Süre: ' + Math.ceil(remaining / 1000) + 's';
+ if (penalties > 0) {
+ timerDisplay += ' (Ceza: ' + penalties + ')';
+ }
+ timerText.setText(timerDisplay);
if (remaining <= 0) {
isGameActive = false;
showMessage("Süre doldu! Oda sıfırlanıyor...");
LK.setTimeout(function () {