User prompt
in headphone screen also add on the top of the screen, a direct link to each level that exists. This will only be used for development purposes and deleted later.
User prompt
in headphone screen also add on the top of the screen, a direct link to each level that exists. This will only be used for development purposes and deleted later.
User prompt
Now the rock is not moving when draggin
User prompt
Better! howerver the first time I touch the rock it moves to another position. it shouldn't. should only move when I drag it
User prompt
It is better, but the drag point of the rock is weird, it is not in the center of the tap
User prompt
Why is the dragging of the rock in puzzle 3 weird and flickering
User prompt
puzzle 3 elelemnts shouldnot change their position afterthe puzzle starts. the position they have should be final,except for rock thatcan be dragge
User prompt
puzzle 3 shouldnot endwhen rock is on tile. rock on tile will open the gate, but player hast to doubletap on gateto go through it afteris open
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'var localPos = self.parent.toLocal(obj.position);' Line Number: 215
User prompt
why are elements on puzzle 3 rearrangeing its position after the first touch
User prompt
for puzzle 3 on double tap of the tiel, you should unify the message that says, the gate opens, but closes down right after you lift your feet
User prompt
Dragging of elelments like the rock in puzzle 3 is bad. should be smoother. please fix.
User prompt
puzzle 3 dragging of the rock is not very smooth, can you fix it.
User prompt
Lets create a third puzzle. This puzzle will have 3 elements. a Gate, a loose floor tile, and a heavy rock. When player holds the floor tile the gate opens, but when released it it released. so to keep the gate open and exit the room, player has to drag the heavy rock and leave it in on top of the floor tile. when draggin, make a noise (and write the text) when the rock is on top of the tile.
User prompt
When I double tap on the tapcircle, i am getting the double tap action and then inmediatelly the single tap. Lets add a check that if an elelemt is double tapped then we need to wait for a single tap to be executed agter the doinle tap finishes
User prompt
There is a weird behaviour, if i double tap in the 180 radius it works okay, but if I double tap in the center of the element then the double tap is executed, but the single tap also. This should not happen. Whne doudle tapping even on the asset, only double tap shoild be executed
User prompt
Can we just merge them and always use the doible tap radius and it will actually be update by the size of the tap asset
User prompt
I want to actually have an asste that represents the double tap radius area
User prompt
Still not working. For exmple when i double tap in the door after I have the key, it opens it but I get the text of a heavy wooden door, instead of the unlocking of it
User prompt
When I double tap and the item is not removed, it executes the double tap, but on thebsecond tap it executes the single tap action. This should bot happen. If double tap happens then sibgle tap should not be excecuted
User prompt
Double tap on items work correctly if I tap outsied of the asset of the element, while if i singe tap on the asset does the single click. I want to always have to tap in the asste, for single and double click and idnetify them separately and not overlap the action
User prompt
Single tap is somethimes not working. Fix it withough messing with double tap
User prompt
When I double tap make sure the second tap does not execute the single tap in an element
User prompt
If element is single tapped, do single tap action, but if dounle tapped do double tap action. Make sure they are not confused
User prompt
Remove area that only detects single click
/**** * 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 () { // If onInteract is defined, it is responsible for calling setGuiText. if (typeof self.onInteract === "function") { self.onInteract(); } else { // Only call setGuiText here if there's no specific onInteract handler // that would call it. This uses the generic interactText and voiceOverInteractId. setGuiText(self.interactText, self.voiceOverInteractId); } }; // Track pending voice-over timeout self.pendingVOTimeout = null; self.justDoubleTapped = false; self.justDoubleTappedTimeout = 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; } // Stop any current voice-over before playing the double-tap VO if (currentVoiceOver) { currentVoiceOver.stop(); currentVoiceOver = null; } self.interact(); self.lastTapTime = 0; // Reset to prevent triple taps // Cooldown after double tap to prevent immediate single tap on this element if (self.justDoubleTappedTimeout) { LK.clearTimeout(self.justDoubleTappedTimeout); } self.justDoubleTapped = true; self.justDoubleTappedTimeout = LK.setTimeout(function () { self.justDoubleTapped = false; self.justDoubleTappedTimeout = null; }, 700); // 700ms cooldown // Play a subtle sound to indicate interaction LK.getSound('sfx_tap').play(); } else { // This is a single tap // If a double tap just occurred on this element, suppress the immediate single tap action // but record the tap time for a potential new double tap. if (self.justDoubleTapped) { self.lastTapTime = now; // Do not schedule announce, do not clear other timers or VOs, as the double tap just handled interaction. } else { // Standard single tap logic: // Cancel any existing pending voice-over if (self.pendingVOTimeout) { LK.clearTimeout(self.pendingVOTimeout); // {s} self.pendingVOTimeout = null; // Explicitly nullify the handle after clearing an old timeout } // {t} // Stop any current voice-over before scheduling new one if (currentVoiceOver) { currentVoiceOver.stop(); currentVoiceOver = null; } // 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) { LK.getSound('sfx_rock_door_rumble').play(); 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; LK.getSound('sfx_key_pickup').play(); 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; }); // Heavy Rock for Puzzle 3 var HeavyRock = InteractiveElement.expand(function () { var self = InteractiveElement.call(this); self.isDragging = false; self.startX = 0; self.startY = 0; self.lastDragSoundTime = 0; self.setup("Heavy Rock", "A large, heavy rock. It might be moveable with effort.", "", function () { setGuiText("The rock is heavy but you might be able to drag it. Hold and drag to move it.", 'vo_rock_drag_hint'); }, 'vo_heavy_rock_label', 'vo_rock_drag_hint'); // Override down to start dragging var originalDown = self.down; self.down = function (x, y, obj) { originalDown.call(self, x, y, obj); // Check if this is a hold (not a double tap) var now = Date.now(); var timeSinceLastTap = now - self.lastTapTime; // If not a double tap, prepare for dragging but do not move the rock yet if (timeSinceLastTap > 500 || timeSinceLastTap < 50) { self.isDragging = false; // Will only start dragging on move self.startX = self.x; self.startY = self.y; // Store the offset between the tap point and the rock's center self.dragOffsetX = self.x - x; self.dragOffsetY = self.y - y; // Do not move the rock here! // Actual dragging will start on move event } }; // Handle dragging self.handleDrag = function (x, y, obj) { // Start dragging if not already started, and this is the first move after tap if (!self.isDragging) { self.isDragging = true; // When starting drag, recalculate offset so the rock doesn't jump self.dragOffsetX = self.x - x; self.dragOffsetY = self.y - y; } // Move the rock to follow the drag with offset self.x = x + self.dragOffsetX; self.y = y + self.dragOffsetY; // Play drag sound periodically var now = Date.now(); if (now - self.lastDragSoundTime > 500) { LK.getSound('sfx_rock_drag').play(); self.lastDragSoundTime = now; } }; // Stop dragging on up self.up = function (x, y, obj) { if (self.isDragging) { self.isDragging = false; // Check if rock is on the floor tile if (puzzle3FloorTile && self.intersects(puzzle3FloorTile)) { puzzle3FloorTile.pressWithRock(); } else if (puzzle3FloorTile && puzzle3FloorTile.isPressedByRock) { // Rock was moved off the tile puzzle3FloorTile.releaseFromRock(); } } }; return self; }); // Gate for Puzzle 3 var Gate = InteractiveElement.expand(function () { var self = InteractiveElement.call(this); self.isOpen = false; // Override announce to provide different instructions when open var originalAnnounce = self.announce; self.announce = function () { if (self.isOpen) { setGuiText("Gate\nThe gate stands open before you.\n(Double tap to pass through)", 'vo_gate_open_announce'); } else { originalAnnounce.call(self); } }; self.setup("Gate", "A heavy iron gate blocks your path.", "", function () { if (self.isOpen) { // When gate is open, double-tap allows passage setGuiText("The gate is open! You step through carefully...", 'vo_gate_passage'); LK.getSound('sfx_success').play(); goToState(STATE_PUZZLE3_SUCCESS); } else { setGuiText("The gate is closed. Something needs to keep it open.", 'vo_gate_closed'); } }, 'vo_gate_label', 'vo_gate_closed'); self.open = function () { if (!self.isOpen) { self.isOpen = true; LK.getSound('sfx_gate_open').play(); setGuiText("The gate slowly grinds open!", 'vo_gate_opening'); } }; self.close = function () { if (self.isOpen) { self.isOpen = false; LK.getSound('sfx_gate_close').play(); setGuiText("The gate slides shut again.", 'vo_gate_closing'); } }; return self; }); // Floor Tile for Puzzle 3 var FloorTile = InteractiveElement.expand(function () { var self = InteractiveElement.call(this); self.isPressed = false; self.isPressedByRock = false; self.linkedGate = null; self.setup("Floor Tile", "A loose stone tile. It seems to move slightly when touched.", "", function () { if (self.isPressedByRock) { setGuiText("The heavy rock keeps the tile pressed down.", 'vo_tile_pressed_by_rock'); } else { setGuiText("When you press the tile, the gate opens... but it closes as soon as you lift your feet. You'll need something heavy to keep it pressed.", 'vo_tile_springs_back'); } }, 'vo_floor_tile_label', 'vo_tile_springs_back'); // Override down to handle holding var originalDown = self.down; self.down = function (x, y, obj) { originalDown.call(self, x, y, obj); // If not already pressed by rock, handle manual press if (!self.isPressedByRock) { self.isPressed = true; if (self.linkedGate) { self.linkedGate.open(); } } }; // Add up handler for release self.up = function (x, y, obj) { // Only handle release if not pressed by rock if (!self.isPressedByRock && self.isPressed) { self.isPressed = false; if (self.linkedGate) { self.linkedGate.close(); } } }; self.pressWithRock = function () { if (!self.isPressedByRock) { self.isPressedByRock = true; self.isPressed = true; if (self.linkedGate) { self.linkedGate.open(); } LK.getSound('sfx_rock_place').play(); setGuiText("The rock settles onto the tile with a satisfying thunk. The gate remains open!", 'vo_rock_on_tile'); } }; self.releaseFromRock = function () { if (self.isPressedByRock) { self.isPressedByRock = false; self.isPressed = false; if (self.linkedGate) { self.linkedGate.close(); } } }; 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'); // Play new door unlock sound LK.getSound('sfx_door_unlock').play(); 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; // Play chest open sound LK.getSound('sfx_chest_open').play(); // Vial Chest if (self.isVialChest) { hasVialOfClarity = true; // Play background music for vial chest open LK.playMusic('vial_chest_open_bgm', { loop: true }); // If trap was already triggered, heal and stop distortion if (trapActive) { trapActive = false; // Stop annoying trap sound if running stopAnnoyingTrapSound(); 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(); // Stop annoying trap sound if running stopAnnoyingTrapSound(); } 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(); // Start annoying trap sound startAnnoyingTrapSound(); // 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 ****/ // missing, added // missing, added // missing, added // missing, added // missing, added // missing, added // missing, added // missing, added // missing, added // missing, added // missing, added // missing, added // missing, added // missing, added // missing, added // missing, added // Narration music tracks // Voice-over sounds for game states and feedback // Voice-over sounds for puzzle elements // Narration assets // Voice-over assets for all text displays // Voice-over sounds for narration // --- State Management --- // No visual assets needed for MVP, but we will use a simple shape for tap feedback. // Audio assets (narration and sfx) are referenced by id, LK will load them automatically. // Voice-over assets for "nothing here" phrases // Puzzle 1 & 2: All unique VO assets 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 STATE_PUZZLE3 = 7; var STATE_PUZZLE3_SUCCESS = 8; 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; // --- Puzzle 3 element state --- var puzzle3Elements = []; var puzzle3Gate = null; var puzzle3FloorTile = null; var puzzle3Rock = null; // --- Annoying sound for trap logic --- var annoyingTrapSound = null; var annoyingTrapSoundInterval = null; function startAnnoyingTrapSound() { if (annoyingTrapSoundInterval) return; // Already running // Play the annoying sound as looping music LK.playMusic('sfx_trap_trigger', { loop: true }); } function stopAnnoyingTrapSound() { // Stop the annoying trap music if playing LK.stopMusic(); if (annoyingTrapSoundInterval) { LK.clearInterval(annoyingTrapSoundInterval); annoyingTrapSoundInterval = null; } annoyingTrapSound = null; } // --- 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, but delay if a SFX is currently playing if (voiceOverId) { // Check if a SFX was just played (by convention, SFX are played right before setGuiText) // We'll check if any SFX is currently playing and delay VO until it finishes var sfxIds = ['sfx_door_unlock', 'sfx_success', 'sfx_tap']; var maxSfxDuration = 0; for (var i = 0; i < sfxIds.length; i++) { var sfx = LK.getSound(sfxIds[i]); if (sfx && sfx.isPlaying && typeof sfx.duration === "number") { if (sfx.duration > maxSfxDuration) { maxSfxDuration = sfx.duration; } } } // If any SFX is playing, delay VO by the max duration (or a minimum of 400ms) if (maxSfxDuration > 0) { LK.setTimeout(function () { currentVoiceOver = LK.getSound(voiceOverId); currentVoiceOver.play(); }, Math.max(400, maxSfxDuration * 1000)); } else { 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'); // Start dungeon background sounds LK.playMusic('dungeon_background_sounds'); // 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(); } } } else if (state === STATE_PUZZLE2) { setGuiText("A quiet chamber. Faint scents and the weight of stone surround you.", '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 = []; } // Stop annoying trap sound if running stopAnnoyingTrapSound(); // Individual success narration for puzzle2 setGuiText("A deep rumble. The door yields, revealing the unknown beyond.", 'vo_puzzle2_success'); // Transition to puzzle 3 after a delay LK.setTimeout(function () { goToState(STATE_PUZZLE3); }, 3000); } else if (state === STATE_PUZZLE3) { setGuiText("Another chamber. You sense a gate ahead, but something blocks it.", 'vo_puzzle3_intro'); // Don't clear puzzle 3 elements, just remove them from display if needed if (puzzle3Elements.length > 0) { for (var i = 0; i < puzzle3Elements.length; i++) { if (puzzle3Elements[i].parent) { puzzle3Elements[i].parent.removeChild(puzzle3Elements[i]); } } } // Only generate positions if elements don't exist yet if (puzzle3Elements.length === 0) { // Generate positions for puzzle 3 elements 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 }); } } // Create gate puzzle3Gate = new Gate(); puzzle3Gate.x = positions[0].x; puzzle3Gate.y = positions[0].y; game.addChild(puzzle3Gate); puzzle3Elements.push(puzzle3Gate); // Create floor tile puzzle3FloorTile = new FloorTile(); puzzle3FloorTile.x = positions[1].x; puzzle3FloorTile.y = positions[1].y; puzzle3FloorTile.linkedGate = puzzle3Gate; game.addChild(puzzle3FloorTile); puzzle3Elements.push(puzzle3FloorTile); // Create heavy rock puzzle3Rock = new HeavyRock(); puzzle3Rock.x = positions[2].x; puzzle3Rock.y = positions[2].y; game.addChild(puzzle3Rock); puzzle3Elements.push(puzzle3Rock); } else { // Re-add existing elements to the game for (var i = 0; i < puzzle3Elements.length; i++) { game.addChild(puzzle3Elements[i]); } } } else if (state === STATE_PUZZLE3_SUCCESS) { var showPuzzle3Congrats = function showPuzzle3Congrats() { if (waitingForPuzzle3Congrats) { waitingForPuzzle3Congrats = false; setGuiText("Congratulations! You've completed all three puzzles.\n\nThank you for playing!", 'vo_game_complete'); } }; // Clean up puzzle 3 elements if (puzzle3Elements.length > 0) { for (var i = 0; i < puzzle3Elements.length; i++) { puzzle3Elements[i].destroy(); } puzzle3Elements = []; } setGuiText("Success! The gate remains open. You've mastered the chamber's mechanics.", 'vo_puzzle3_success'); var waitingForPuzzle3Congrats = true; var voSuccess = LK.getSound('vo_puzzle3_success'); if (voSuccess) { voSuccess.onEnded = function () { showPuzzle3Congrats(); }; } // Also allow player to tap to continue var oldDown = game.down; game.down = function (x, y, obj) { if (currentState === STATE_PUZZLE3_SUCCESS && waitingForPuzzle3Congrats) { showPuzzle3Congrats(); return; } if (typeof oldDown === "function") oldDown(x, y, obj); }; } 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; // First check if tap is on an interactive element var tappedElement = null; var tapOnElement = false; // 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) { tappedElement = el; tapOnElement = 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) { tappedElement = el; tapOnElement = true; break; } } } // If tapping on an element, let the element handle voice-over management // Only stop voice-over if NOT tapping on an element, or if it's a single tap on non-interactive area if (currentVoiceOver && !tapOnElement) { 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) { // Continue to puzzle 3 goToState(STATE_PUZZLE3); } else if (currentState === STATE_PUZZLE3) { // Route tap to nearest element var tapped = false; for (var i = 0; i < puzzle3Elements.length; i++) { var el = puzzle3Elements[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) { // Random 'nothing here' feedback 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" }]; var idx = Math.floor(Math.random() * nothingHerePhrasesVO.length); setGuiText(nothingHerePhrasesVO[idx].text, nothingHerePhrasesVO[idx].vo); } } else if (currentState === STATE_PUZZLE3_SUCCESS) { // Game complete - could restart or show credits goToState(STATE_HEADPHONES); } }; // Prevent drag/hold from causing issues game.move = function (x, y, obj) { // Handle rock dragging in puzzle 3 if (currentState === STATE_PUZZLE3 && puzzle3Rock && puzzle3Rock.isDragging) { puzzle3Rock.handleDrag(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); } } } } else if (currentState === STATE_PUZZLE3) { // Handle release for puzzle 3 elements for (var i = 0; i < puzzle3Elements.length; i++) { var el = puzzle3Elements[i]; if (typeof el.up === "function") { // Check if release is near the element var dx = x - el.x; var dy = y - el.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < 180 || el.isDragging || el.isPressed) { el.up(x, y, obj); } } } // Do not automatically complete puzzle when rock is on tile // Player must double-tap the open gate to proceed } }; // --- Game Start --- goToState(STATE_HEADPHONES);
===================================================================
--- original.js
+++ change.js
@@ -171,8 +171,11 @@
self.handleDrag = function (x, y, obj) {
// Start dragging if not already started, and this is the first move after tap
if (!self.isDragging) {
self.isDragging = true;
+ // When starting drag, recalculate offset so the rock doesn't jump
+ self.dragOffsetX = self.x - x;
+ self.dragOffsetY = self.y - y;
}
// Move the rock to follow the drag with offset
self.x = x + self.dragOffsetX;
self.y = y + self.dragOffsetY;
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