User prompt
do not show the congratulations message untill the puzzle 2 completion message is finished or even after the player taps
User prompt
add rock door rumble when rock door is opened in puzzle 2
User prompt
add vo sound for A deep rumble. The door yields, revealing the unknown beyond.
User prompt
before showing congratulation of completing both puzzles, lets add a individual success for the puzzle2 like puzzle1 had. it should read: A deep rumble. The door yields, revealing the unknown beyond.
User prompt
create a backgounr music to be played when the vial chest is open
User prompt
add sfx when a chest is open
User prompt
create and play a sfx when the key is picked
User prompt
when a sfx is played before a VO, let the sound play and then the VO start
User prompt
in puzzle1, add a new sound to be played when door is unlocked. do not remove any of the current sounds.
User prompt
make sure sfx_trap_trigger stops when vial chest is open
User prompt
sft_trap_trigger should better be music instead of just a sound
User prompt
in puzzle2, if player opens the trap without the vial, I wan to play an annoying sound until the player opens the chest with the vial that stops the sound.
User prompt
add a sound when vial of clarity is picked, and also a sound that will be played if player opens first the trap
User prompt
create va asset for The door is locked tight. You'll need something to open it
User prompt
when puzzle1 starts, start playing dungeon_background_sounds
User prompt
some events will not only show some text and read the VO, but they will also have an extra sound. for example in puzzle 1, I want to make the sound of a key turning when you open the door.
User prompt
create vo assets for all missing text
Code edit (1 edits merged)
Please save this source code
User prompt
double tapping on an element is not playing the VO of the text. something is wrong there. can we fix it?
User prompt
PLease fix The fundamental issue is that the double-tap detection and voice-over management is split between two different levels (game level and element level) that don't properly coordinate with each other, causing timing conflicts when both try to manage the voice-over state.
User prompt
So we have a problem. Voice over sometimes is different when I tap that when I double tap. So we need to make sure that if the player is double tapping, we are not starting the tap Voice over first.
User prompt
remove not from game since we are not using it
User prompt
clearly differenciate tap from double tap
User prompt
when I double click on an item to interact with it, the narration does not play. or maybe it is stopped on the second tap. can we add an exception not to stop a sound if it hasbeen open with a double tap
User prompt
when I double click on an item to interact with it, the narration does not play. or maybe it is stopped on the second tap. can we add an exception not to stop a sound if it hasbeen open with a double tap
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var InteractiveElement = Container.expand(function () { var self = Container.call(this); self.label = ""; self.description = ""; self.interactText = ""; self.onInteract = null; self.voiceOverAnnounceId = null; self.voiceOverInteractId = null; self.lastTapTime = 0; self.tapCount = 0; // Visual: use tapCircle for all, but color can be changed if needed var circle = self.attachAsset('tapCircle', { anchorX: 0.5, anchorY: 0.5, alpha: 0.7 }); // Set up element self.setup = function (label, description, interactText, onInteract, voiceOverAnnounceId, voiceOverInteractId) { self.label = label; self.description = description; self.interactText = interactText; self.onInteract = onInteract; self.voiceOverAnnounceId = voiceOverAnnounceId; self.voiceOverInteractId = voiceOverInteractId; }; // Announce what this is self.announce = function () { setGuiText(self.label + "\n" + self.description + "\n(Double tap to interact)", self.voiceOverAnnounceId); // Optionally, play a sound or narration for the element }; // Interact with the element self.interact = function () { setGuiText(self.interactText, self.voiceOverInteractId); if (typeof self.onInteract === "function") { self.onInteract(); } }; // Track pending voice-over timeout self.pendingVOTimeout = null; // Handle tap/double-tap self.down = function (x, y, obj) { var now = Date.now(); var timeSinceLastTap = now - self.lastTapTime; // If within double-tap window if (timeSinceLastTap < 500 && timeSinceLastTap > 50) { // Added minimum time to avoid accidental double taps // This is a double tap // Cancel any pending single-tap voice-over if (self.pendingVOTimeout) { LK.clearTimeout(self.pendingVOTimeout); self.pendingVOTimeout = null; } self.interact(); self.lastTapTime = 0; // Reset to prevent triple taps // Play a subtle sound to indicate interaction LK.getSound('sfx_tap').play(); } else { // This is a single tap // Cancel any existing pending voice-over if (self.pendingVOTimeout) { LK.clearTimeout(self.pendingVOTimeout); } // Delay the announce to check if it's actually a double-tap self.pendingVOTimeout = LK.setTimeout(function () { self.announce(); self.pendingVOTimeout = null; }, 300); // Wait 300ms to see if second tap comes self.lastTapTime = now; } }; return self; }); // Stone Door for Puzzle 2 var StoneDoor = InteractiveElement.expand(function () { var self = InteractiveElement.call(this); self.setup("Stone Door", "A massive stone door blocks your path.", "", function () { if (bothChestsOpened) { setGuiText("The stone door grinds open. You've solved the puzzle!", 'vo_stone_door_open'); LK.getSound('sfx_success').play(); goToState(STATE_PUZZLE2_SUCCESS); } else { setGuiText("The door won't budge. Perhaps something else needs to be done first.", 'vo_stone_door_locked'); } }, 'vo_stone_door_label', 'vo_stone_door_locked'); return self; }); // Key var Key = InteractiveElement.expand(function () { var self = InteractiveElement.call(this); self.setup("Key", "Something lies on the floor. Cold, small... metal.", "You pick up a rusty key. It hums faintly in your hand.", function () { hasKey = true; setGuiText("You pick up a rusty key. It hums faintly in your hand.", 'vo_key_pickup'); self.visible = false; // Hide key after pickup }, 'vo_key_label', 'vo_key_pickup'); return self; }); // Door var Door = InteractiveElement.expand(function () { var self = InteractiveElement.call(this); self.setup("Door", "A heavy wooden door. It doesn't budge.", "", function () { // Door can only be opened if player has the key if (typeof hasKey !== "undefined" && hasKey) { self.interactText = "The key turns with a satisfying click. The path ahead opens."; setGuiText("The key turns with a satisfying click. The path ahead opens.", 'vo_door_unlocked'); goToState(STATE_PUZZLE1_SUCCESS); } else { self.interactText = "The door is locked tight. You'll need something to open it."; setGuiText("The door is locked tight. You'll need something to open it.", 'vo_door_locked'); } }, 'vo_door_label', 'vo_door_locked'); return self; }); // Chest for Puzzle 2 var Chest = InteractiveElement.expand(function () { var self = InteractiveElement.call(this); self.isOpened = false; self.chestId = 0; self.isVialChest = false; // Will be set during setup self.isTrapChest = false; // Will be set during setup self.setup = function (id, isVial, isTrap) { self.chestId = id; self.isVialChest = !!isVial; self.isTrapChest = !!isTrap; // Inspection text var inspectText = "A wooden chest with intricate carvings."; if (self.isVialChest) { inspectText = "A wooden chest. It smells faintly of herbs."; } else if (self.isTrapChest) { inspectText = "Another chest, this one colder to the touch."; } // Interact logic InteractiveElement.call(self).setup("Chest " + (id + 1), inspectText, "", function () { if (!self.isOpened) { self.isOpened = true; // Vial Chest if (self.isVialChest) { hasVialOfClarity = true; // If trap was already triggered, heal and stop distortion if (trapActive) { trapActive = false; var vialText = "You open the chest… a soft chime rings out. Inside, a small vial, warm to the touch. You feel a little more focused. The distortion fades."; // If this is the second chest, append the stone shifting message var openedCount = 0; for (var i = 0; i < puzzle2Elements.length; i++) { if (puzzle2Elements[i] instanceof Chest && puzzle2Elements[i].isOpened) { openedCount++; } } if (openedCount === 2) { vialText += "\nYou hear a heavy stone shifting nearby."; } setGuiText(vialText, 'vo_vial_heals_trap'); // Play soft chime, then steady hum (simulate with sfx_success for now) LK.getSound('sfx_success').play(); } else { var vialText = "You open the chest… a soft chime rings out. Inside, a small vial, warm to the touch. You feel a little more focused."; var openedCount = 0; for (var i = 0; i < puzzle2Elements.length; i++) { if (puzzle2Elements[i] instanceof Chest && puzzle2Elements[i].isOpened) { openedCount++; } } if (openedCount === 2) { vialText += "\nYou hear a heavy stone shifting nearby."; } setGuiText(vialText, 'vo_vial_found'); LK.getSound('sfx_success').play(); } } // Trap Chest else if (self.isTrapChest) { // If player already has vial, neutralize trap if (hasVialOfClarity) { var trapText = "You open the chest… a rush of wind escapes, but the vial in your hand pulses gently, shielding your senses."; var openedCount = 0; for (var i = 0; i < puzzle2Elements.length; i++) { if (puzzle2Elements[i] instanceof Chest && puzzle2Elements[i].isOpened) { openedCount++; } } if (openedCount === 2) { trapText += "\nYou hear a heavy stone shifting nearby."; } setGuiText(trapText, 'vo_trap_neutralized'); // Play wind muffled/steady hum (simulate with sfx_tap for now) LK.getSound('sfx_tap').play(); } else { trapActive = true; var trapText = "You open the chest… a rush of wind escapes. A sharp whisper pierces your ears. Everything feels… twisted."; var openedCount = 0; for (var i = 0; i < puzzle2Elements.length; i++) { if (puzzle2Elements[i] instanceof Chest && puzzle2Elements[i].isOpened) { openedCount++; } } if (openedCount === 2) { trapText += "\nYou hear a heavy stone shifting nearby."; } setGuiText(trapText, 'vo_trap_triggered'); // Play rushing wind/sharp whisper (simulate with sfx_tap for now) LK.getSound('sfx_tap').play(); // TODO: Add actual distortion effect if available } } // Fallback (should not happen) else { var fallbackText = "The chest creaks open. You find nothing inside, but sense progress."; var openedCount = 0; for (var i = 0; i < puzzle2Elements.length; i++) { if (puzzle2Elements[i] instanceof Chest && puzzle2Elements[i].isOpened) { openedCount++; } } if (openedCount === 2) { fallbackText += "\nYou hear a heavy stone shifting nearby."; } setGuiText(fallbackText, 'vo_chest_opened'); LK.getSound('sfx_success').play(); } checkPuzzle2Progress(); } else { setGuiText("The chest is already open.", 'vo_chest_empty'); } }, // Announce/inspect voice-over self.isVialChest ? 'vo_vial_inspect' : self.isTrapChest ? 'vo_trap_inspect' : 'vo_chest_label', // Interact voice-over self.isVialChest ? 'vo_vial_found' : self.isTrapChest ? 'vo_trap_triggered' : 'vo_chest_opened'); }; return self; }); // Chest // Simple visual feedback for taps (for sighted users or those with some vision) var TapFeedback = Container.expand(function () { var self = Container.call(this); var circle = self.attachAsset('tapCircle', { anchorX: 0.5, anchorY: 0.5, alpha: 0.5 }); self.showAt = function (x, y) { self.x = x; self.y = y; self.alpha = 0.5; self.scaleX = 1; self.scaleY = 1; tween(self, { alpha: 0, scaleX: 2, scaleY: 2 }, { duration: 400, easing: tween.easeOut, onFinish: function onFinish() { self.destroy(); } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Puzzle 1 & 2: All unique VO assets // Voice-over assets for "nothing here" phrases // Audio assets (narration and sfx) are referenced by id, LK will load them automatically. // No visual assets needed for MVP, but we will use a simple shape for tap feedback. // --- State Management --- // Voice-over sounds for narration // Voice-over assets for all text displays // Narration assets // Voice-over sounds for puzzle elements // Voice-over sounds for game states and feedback // Narration music tracks var STATE_HEADPHONES = 0; var STATE_MENU = 1; var STATE_INTRO = 2; var STATE_PUZZLE1 = 3; var STATE_PUZZLE1_SUCCESS = 4; var STATE_PUZZLE2 = 5; var STATE_PUZZLE2_SUCCESS = 6; var currentState = STATE_HEADPHONES; var headphonesIcon = null; // Store reference to headphones icon // Used to prevent double-tap triggers var inputLocked = false; // Used to track narration/music var currentNarration = null; // Used to track current voice-over sound var currentVoiceOver = null; // Used for puzzle state var puzzle1Step = 0; // 0 = waiting for first tap, 1 = waiting for second tap // Double-tap tracking at game level var lastTapTime = 0; var lastTapX = 0; var lastTapY = 0; var doubleTapThreshold = 500; // milliseconds var doubleTapDistanceThreshold = 50; // pixels // --- Puzzle 1 element state --- var puzzle1Elements = []; var chestOpened = false; var hasKey = false; // --- Puzzle 2 element state --- var puzzle2Elements = []; var bothChestsOpened = false; // --- Puzzle 2: Vial/Trap state --- var hasVialOfClarity = false; var trapActive = false; // --- GUI Text for minimal visual feedback (for sighted users) --- var guiText = new Text2('', { size: 50, fill: 0xFFFFFF, wordWrap: true, wordWrapWidth: 1800, // Allow text wrapping align: 'center' // Center align the text lines within the text object }); guiText.anchor.set(0.5, 1.0); LK.gui.bottom.addChild(guiText); guiText.y = -50; // Offset from bottom edge // --- Helper Functions --- function playNarration(id, options) { // Stop any current narration/music LK.stopMusic(); currentNarration = id; LK.playMusic(id, options || {}); } function stopNarration() { LK.stopMusic(); currentNarration = null; } function setGuiText(txt, voiceOverId) { guiText.setText(txt); // Add a subtle scale animation when text updates guiText.scaleX = 1.1; guiText.scaleY = 1.1; tween(guiText, { scaleX: 1, scaleY: 1 }, { duration: 300, easing: tween.easeOut }); // Stop current voice-over if playing if (currentVoiceOver) { currentVoiceOver.stop(); currentVoiceOver = null; } // Play voice-over if provided if (voiceOverId) { currentVoiceOver = LK.getSound(voiceOverId); currentVoiceOver.play(); } } function lockInput(ms) { inputLocked = true; LK.setTimeout(function () { inputLocked = false; }, ms || 600); } // Check if both chests are opened in puzzle 2 function checkPuzzle2Progress() { var openedCount = 0; for (var i = 0; i < puzzle2Elements.length; i++) { if (puzzle2Elements[i] instanceof Chest && puzzle2Elements[i].isOpened) { openedCount++; } } if (openedCount >= 2 && !bothChestsOpened) { bothChestsOpened = true; // No separate message for the door noise; handled in Chest logic after opening the second chest. } } // --- State Transitions --- function goToState(state) { stopNarration(); // Remove headphones icon if it exists if (headphonesIcon) { headphonesIcon.destroy(); headphonesIcon = null; } currentState = state; if (state === STATE_HEADPHONES) { setGuiText("Use Headphones for a better experience.\n\n(Tap to continue)"); // Added two extra newlines // Voice-over is already handled by playNarration playNarration('screen_headphones_voice', { loop: false }); // Add headphones icon headphonesIcon = LK.getAsset('headphonesIcon', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 // Center icon on screen }); game.addChild(headphonesIcon); } else if (state === STATE_MENU) { setGuiText("Title screen...\n\n(Tap to start)", 'vo_menu_title'); // This ensures the menu title voice-over is played // No narration for menu, or could add a short one if desired } else if (state === STATE_INTRO) { setGuiText("Loading story...\n\n(Tap to continue)", 'vo_loading_story'); playNarration('narr_intro'); // Wait for tap to continue instead of auto-advancing } else if (state === STATE_PUZZLE1) { setGuiText("Darkness surrounds you.\nTap to feel your way forward.\nDouble tap when something stirs... it may be more than stone.", 'vo_dungeon_intro'); playNarration('narr_puzzle1'); // Only create elements if they don't exist yet if (typeof puzzle1Elements === "undefined" || puzzle1Elements.length === 0) { puzzle1Step = 0; puzzle1Elements = []; chestOpened = false; hasKey = false; // Random positions for puzzle 1 elements var positions = []; // Generate random positions ensuring they don't overlap and are within bounds for (var p = 0; p < 2; p++) { var validPosition = false; var attempts = 0; while (!validPosition && attempts < 50) { var newX = 200 + Math.random() * (2048 - 400); // Keep away from edges var newY = 400 + Math.random() * (2732 - 800); // Keep away from edges and top menu // Check if position is far enough from existing positions var tooClose = false; for (var existingPos = 0; existingPos < positions.length; existingPos++) { var dx = newX - positions[existingPos].x; var dy = newY - positions[existingPos].y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 300) { // Minimum distance between elements tooClose = true; break; } } if (!tooClose) { positions.push({ x: newX, y: newY }); validPosition = true; } attempts++; } // Fallback if no valid position found after attempts if (!validPosition) { positions.push({ x: 400 + p * 600, y: 800 + p * 400 }); } } // Key var key = new Key(); key.x = positions[0].x; key.y = positions[0].y; game.addChild(key); puzzle1Elements.push(key); // Door var door = new Door(); door.x = positions[1].x; door.y = positions[1].y; game.addChild(door); puzzle1Elements.push(door); } } else if (state === STATE_PUZZLE1_SUCCESS) { // Remove puzzle elements if (typeof puzzle1Elements !== "undefined") { for (var i = 0; i < puzzle1Elements.length; i++) { puzzle1Elements[i].destroy(); } } setGuiText("Well done! The door opens to reveal another chamber.\n\n(Tap to continue)", 'vo_puzzle1_complete'); } else if (state === STATE_PUZZLE2) { setGuiText("A new chamber. You sense chests and a heavy stone door.\nExplore carefully.", 'vo_puzzle2_intro'); // Clear previous puzzle elements if (puzzle2Elements.length > 0) { for (var i = 0; i < puzzle2Elements.length; i++) { puzzle2Elements[i].destroy(); } } puzzle2Elements = []; bothChestsOpened = false; hasVialOfClarity = false; trapActive = false; // Generate random positions for 2 chests and 1 door var positions = []; for (var p = 0; p < 3; p++) { var validPosition = false; var attempts = 0; while (!validPosition && attempts < 50) { var newX = 300 + Math.random() * (2048 - 600); var newY = 500 + Math.random() * (2732 - 1000); var tooClose = false; for (var existingPos = 0; existingPos < positions.length; existingPos++) { var dx = newX - positions[existingPos].x; var dy = newY - positions[existingPos].y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 400) { tooClose = true; break; } } if (!tooClose) { positions.push({ x: newX, y: newY }); validPosition = true; } attempts++; } if (!validPosition) { positions.push({ x: 400 + p * 500, y: 900 + p * 300 }); } } // Randomly assign which chest is Vial and which is Trap var vialChestIndex = Math.floor(Math.random() * 2); var trapChestIndex = 1 - vialChestIndex; // Create chests for (var c = 0; c < 2; c++) { var chest = new Chest(); var isVial = c === vialChestIndex; var isTrap = c === trapChestIndex; chest.setup(c, isVial, isTrap); chest.x = positions[c].x; chest.y = positions[c].y; game.addChild(chest); puzzle2Elements.push(chest); } // Create stone door (always visible) var stoneDoor = new StoneDoor(); stoneDoor.x = positions[2].x; stoneDoor.y = positions[2].y; stoneDoor.visible = true; // Always visible game.addChild(stoneDoor); puzzle2Elements.push(stoneDoor); } else if (state === STATE_PUZZLE2_SUCCESS) { // Clean up puzzle 2 elements if (puzzle2Elements.length > 0) { for (var i = 0; i < puzzle2Elements.length; i++) { puzzle2Elements[i].destroy(); } puzzle2Elements = []; } setGuiText("Congratulations! You've completed both puzzles.\n\nThank you for playing!", 'vo_game_complete'); // Could transition to credits or restart } lockInput(800); } // --- Puzzle 1 Logic --- // For MVP: Simple puzzle, e.g. "Tap twice to continue" function handlePuzzle1Tap() { if (puzzle1Step === 0) { // First tap puzzle1Step = 1; LK.getSound('sfx_tap').play(); // Optionally, play a short instruction or feedback setGuiText("Good! Tap again to solve the puzzle."); lockInput(600); } else if (puzzle1Step === 1) { // Second tap, puzzle solved LK.getSound('sfx_success').play(); goToState(STATE_PUZZLE1_SUCCESS); } } // --- Input Handling --- // Visual tap feedback for sighted users function showTapFeedback(x, y) { var tapFx = new TapFeedback(); tapFx.showAt(x, y); game.addChild(tapFx); } // Main tap handler game.down = function (x, y, obj) { if (inputLocked) { return; } // Check if this is a double-tap at game level var now = Date.now(); var timeSinceLastTap = now - lastTapTime; var tapDistance = Math.sqrt((x - lastTapX) * (x - lastTapX) + (y - lastTapY) * (y - lastTapY)); var isDoubleTap = timeSinceLastTap < doubleTapThreshold && timeSinceLastTap > 50 && tapDistance < doubleTapDistanceThreshold; // Check if double-tap is on an interactive element var isDoubleTapOnElement = false; if (isDoubleTap) { // Check puzzle 1 elements if (currentState === STATE_PUZZLE1 && typeof puzzle1Elements !== "undefined") { for (var i = 0; i < puzzle1Elements.length; i++) { var el = puzzle1Elements[i]; var dx = x - el.x; var dy = y - el.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < 180) { isDoubleTapOnElement = true; break; } } } // Check puzzle 2 elements if (currentState === STATE_PUZZLE2 && typeof puzzle2Elements !== "undefined") { for (var i = 0; i < puzzle2Elements.length; i++) { var el = puzzle2Elements[i]; var dx = x - el.x; var dy = y - el.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < 180) { isDoubleTapOnElement = true; break; } } } } // Stop current voice-over when screen is tapped, only if this is NOT a double-tap on an InteractiveElement if (currentVoiceOver && (!isDoubleTap || !isDoubleTapOnElement)) { currentVoiceOver.stop(); currentVoiceOver = null; } // Update last tap info lastTapTime = now; lastTapX = x; lastTapY = y; showTapFeedback(x, y); if (currentState === STATE_HEADPHONES) { goToState(STATE_MENU); } else if (currentState === STATE_MENU) { goToState(STATE_INTRO); } else if (currentState === STATE_INTRO) { // Tap to continue from intro to puzzle goToState(STATE_PUZZLE1); } else if (currentState === STATE_PUZZLE1) { // Route tap to nearest element if within range, else generic feedback var tapped = false; if (typeof puzzle1Elements !== "undefined") { for (var i = 0; i < puzzle1Elements.length; i++) { var el = puzzle1Elements[i]; var dx = x - el.x; var dy = y - el.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < 180) { // within tapCircle radius if (typeof el.down === "function") { el.down(x, y, obj); tapped = true; break; } } } } if (!tapped) { // Pool of random 'nothing here' phrases and their corresponding voice-over asset ids var nothingHerePhrasesVO = [{ text: "Just cold stone beneath your fingers.", vo: "vo_nothing_cold_stone" }, { text: "Nothing unusual here.", vo: "vo_nothing_unusual" }, { text: "Rough wall. Nothing of interest.", vo: "vo_nothing_rough_wall" }, { text: "Only silence greets you.", vo: "vo_nothing_silence" }, { text: "You reach out… and find nothing new.", vo: "vo_nothing_reach_out" }, { text: "Your hand brushes empty air.", vo: "vo_nothing_brush_air" }, { text: "It’s quiet here. Too quiet.", vo: "vo_nothing_quiet" }, { text: "Nothing but shadows.", vo: "vo_nothing_shadows" }, { text: "This spot feels empty.", vo: "vo_nothing_spot_empty" }, { text: "Just part of the dungeon wall.", vo: "vo_nothing_dungeon_wall" }, { text: "You feel around, but there’s nothing here.", vo: "vo_nothing_feel_around" }, { text: "Only old stone. Try elsewhere.", vo: "vo_nothing_old_stone" }]; // Pick a random phrase and its voice-over var idx = Math.floor(Math.random() * nothingHerePhrasesVO.length); setGuiText(nothingHerePhrasesVO[idx].text, nothingHerePhrasesVO[idx].vo); } } else if (currentState === STATE_PUZZLE1_SUCCESS) { // Continue to puzzle 2 goToState(STATE_PUZZLE2); } else if (currentState === STATE_PUZZLE2) { // Route tap to nearest element var tapped = false; for (var i = 0; i < puzzle2Elements.length; i++) { var el = puzzle2Elements[i]; var dx = x - el.x; var dy = y - el.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < 180) { if (typeof el.down === "function") { el.down(x, y, obj); tapped = true; break; } } } if (!tapped) { // Pool of random 'nothing here' phrases and their corresponding voice-over asset ids var nothingHerePhrasesVO = [{ text: "Just cold stone beneath your fingers.", vo: "vo_nothing_cold_stone" }, { text: "Nothing unusual here.", vo: "vo_nothing_unusual" }, { text: "Rough wall. Nothing of interest.", vo: "vo_nothing_rough_wall" }, { text: "Only silence greets you.", vo: "vo_nothing_silence" }, { text: "You reach out… and find nothing new.", vo: "vo_nothing_reach_out" }, { text: "Your hand brushes empty air.", vo: "vo_nothing_brush_air" }, { text: "It’s quiet here. Too quiet.", vo: "vo_nothing_quiet" }, { text: "Nothing but shadows.", vo: "vo_nothing_shadows" }, { text: "This spot feels empty.", vo: "vo_nothing_spot_empty" }, { text: "Just part of the dungeon wall.", vo: "vo_nothing_dungeon_wall" }, { text: "You feel around, but there’s nothing here.", vo: "vo_nothing_feel_around" }, { text: "Only old stone. Try elsewhere.", vo: "vo_nothing_old_stone" }]; // Pick a random phrase and its voice-over var idx = Math.floor(Math.random() * nothingHerePhrasesVO.length); setGuiText(nothingHerePhrasesVO[idx].text, nothingHerePhrasesVO[idx].vo); } } else if (currentState === STATE_PUZZLE2_SUCCESS) { // Game complete - could restart or show credits goToState(STATE_HEADPHONES); } }; // Prevent drag/hold from causing issues game.move = function (x, y, obj) {}; game.up = function (x, y, obj) { // Route up event to elements for hold detection if (currentState === STATE_PUZZLE1) { if (typeof puzzle1Elements !== "undefined") { for (var i = 0; i < puzzle1Elements.length; i++) { var el = puzzle1Elements[i]; if (typeof el.up === "function" && el.isHolding) { el.up(x, y, obj); } } } } }; // --- Game Start --- goToState(STATE_HEADPHONES);
===================================================================
--- original.js
+++ change.js
@@ -42,23 +42,38 @@
if (typeof self.onInteract === "function") {
self.onInteract();
}
};
+ // Track pending voice-over timeout
+ self.pendingVOTimeout = null;
// Handle tap/double-tap
self.down = function (x, y, obj) {
var now = Date.now();
var timeSinceLastTap = now - self.lastTapTime;
// If within double-tap window
if (timeSinceLastTap < 500 && timeSinceLastTap > 50) {
// Added minimum time to avoid accidental double taps
// This is a double tap
+ // Cancel any pending single-tap voice-over
+ if (self.pendingVOTimeout) {
+ LK.clearTimeout(self.pendingVOTimeout);
+ self.pendingVOTimeout = null;
+ }
self.interact();
self.lastTapTime = 0; // Reset to prevent triple taps
// Play a subtle sound to indicate interaction
LK.getSound('sfx_tap').play();
} else {
// This is a single tap
- self.announce();
+ // Cancel any existing pending voice-over
+ if (self.pendingVOTimeout) {
+ LK.clearTimeout(self.pendingVOTimeout);
+ }
+ // Delay the announce to check if it's actually a double-tap
+ self.pendingVOTimeout = LK.setTimeout(function () {
+ self.announce();
+ self.pendingVOTimeout = null;
+ }, 300); // Wait 300ms to see if second tap comes
self.lastTapTime = now;
}
};
return self;
screen_headphones_voice
Sound effect
vo_menu_title
Sound effect
vo_loading_story
Sound effect
vo_dungeon_intro
Sound effect
vo_nothing_cold_stone
Sound effect
vo_nothing_unusual
Sound effect
vo_nothing_rough_wall
Sound effect
vo_nothing_silence
Sound effect
vo_nothing_reach_out
Sound effect
vo_nothing_brush_air
Sound effect
vo_nothing_quiet
Sound effect
vo_nothing_shadows
Sound effect
vo_nothing_spot_empty
Sound effect
vo_nothing_dungeon_wall
Sound effect
vo_nothing_feel_around
Sound effect
vo_nothing_old_stone
Sound effect
vo_stone_door_label
Sound effect
vo_key_label
Sound effect
vo_key_pickup
Sound effect
vo_door_label
Sound effect
vo_door_unlocked
Sound effect
vo_puzzle2_intro
Sound effect
vo_vial_inspect
Sound effect
vo_vial_found
Sound effect
vo_vial_heals_trap
Sound effect
vo_trap_inspect
Sound effect
vo_trap_triggered
Sound effect
vo_trap_neutralized
Sound effect
dungeon_background_sounds
Music
vo_door_locked
Sound effect
sfx_trap_trigger
Music
sfx_door_unlock
Sound effect
sfx_key_pickup
Sound effect
sfx_chest_open
Sound effect
vial_chest_open_bgm
Music
vo_puzzle2_success
Sound effect
sfx_rock_door_rumble
Sound effect
vo_puzzle3_intro
Sound effect
vo_heavy_rock_label
Sound effect
vo_rock_drag_hint
Sound effect
vo_rock_door_rumble
Sound effect
sfx_rock_drag
Sound effect
vo_gate_label
Sound effect
vo_floor_tile_label
Sound effect
vo_gate_closed
Sound effect
vo_menu_intro
Sound effect
vo_menu_how_to_play
Sound effect
vo_menu_credits
Sound effect
vo_how_to_play_content
Sound effect
vo_credits_content
Sound effect
vo_menu_title_announce
Sound effect
vo_stone_door_locked
Sound effect
sfx_chime_1
Sound effect
sfx_chime_2
Sound effect
sfx_chime_3
Sound effect
sfx_chime_4
Sound effect
vo_chime_description_1
Sound effect
vo_chime_description_2
Sound effect
vo_chime_description_3
Sound effect
vo_chime_description_4
Sound effect
vo_chime_instruction
Sound effect
vo_puzzle4_intro
Sound effect
vo_tap_chimes_hint
Sound effect
vo_puzzle4_wrong
Sound effect
vo_repeat_sequence
Sound effect
vo_puzzle4_success
Sound effect
vo_tile_double_tap
Sound effect
vo_rock_on_tile
Sound effect
sfx_rock_place
Sound effect
vo_gate_open_announce
Sound effect
vo_puzzle5_wrong
Sound effect
vo_puzzle5_intro
Sound effect
vo_puzzle4_simple_intro
Sound effect
vo_puzzle4_simple_success
Sound effect
vo_tile_springs_back
Sound effect
vo_chime_general_description
Sound effect
vo_puzzle3_success
Sound effect
vo_puzzle5_success
Sound effect
vo_game_complete
Sound effect
vo_hint_icon_message
Sound effect