User prompt
OK, make it go up when dead and make it go down when dead again and up when dead, and stays up and down with dead and stays down until up and loops in glitch
User prompt
make it so your player always moves up and down in the glitch room
User prompt
when you die. Once in the glitz thing, your player moves without you moving yourself the player moves. It only moves up and stays up all next time it dies it moves down.
User prompt
if you die five times in the glitch room than it flashes the password for 1 ms
User prompt
OK, delete it delete the error code
User prompt
Please fix the bug: 'Timeout.tick error: Can't find variable: addGlitchRoomArrowButtons' in or related to this line: 'glitchRoomButtons = addGlitchRoomArrowButtons();' Line Number: 3449
User prompt
Please fix the bug: 'Timeout.tick error: Can't find variable: addGlitchRoomArrowButtons' in or related to this line: 'glitchRoomButtons = addGlitchRoomArrowButtons();' Line Number: 3449
User prompt
if you die five times in the glitch then there won’t be any monsters and the password will flash every millisecond on the screen ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
yes, code that
User prompt
A monster can spawn, but it can’t kill you the monster can change sizes from 0-20 a pizza can show up on screen everything can spin and after it spins, it goes back in it’s place it can rotate, and after it rotates, it can go back in its place ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var ArrowButton = Container.expand(function (direction) { var self = Container.call(this); var buttonGraphics = self.attachAsset('arrowButton', { anchorX: 0.5, anchorY: 0.5 }); self.direction = direction; self.down = function (x, y, obj) { self.isPressed = true; buttonGraphics.alpha = 0.7; }; self.up = function (x, y, obj) { self.isPressed = false; buttonGraphics.alpha = 1.0; }; return self; }); // --- Black Room Enemy Class --- var BlackRoomEnemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('monster', { anchorX: 0.5, anchorY: 0.5 }); self.maxHealth = 100; self.health = 100; self.isKnockedOut = false; self.lastX = 0; self.lastY = 0; self.lastPlayerIntersecting = false; self.speed = 2.5; self.update = function () { if (self.isKnockedOut) return; if (typeof blackRoomPlayer !== "undefined" && blackRoomPlayer) { var dx = blackRoomPlayer.x - self.x; var dy = blackRoomPlayer.y - self.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 0) { self.x += dx / dist * self.speed; self.y += dy / dist * self.speed; } // Check if enemy caught player var currentIntersecting = self.intersects(blackRoomPlayer); if (!self.lastPlayerIntersecting && currentIntersecting) { // Player caught! Show lose and restart black room LK.effects.flashScreen(0xff0000, 1000); var loseText = new Text2('You were caught!\nRestarting...', { size: 100, fill: 0xff0000 }); loseText.anchor.set(0.5, 0.5); loseText.x = 1024; loseText.y = 1366; game.addChild(loseText); LK.setTimeout(function () { if (typeof startBlackRoom === "function") startBlackRoom(); }, 1500); } self.lastPlayerIntersecting = currentIntersecting; } }; self.takePizzaHit = function () { if (self.isKnockedOut) return; self.health -= 20; LK.effects.flashObject(self, 0xffff00, 400); if (self.health <= 0) { self.isKnockedOut = true; // Knockout animation var koText = new Text2('Enemy Knocked Out!', { size: 90, fill: 0x00ff00 }); koText.anchor.set(0.5, 0.5); koText.x = 1024; koText.y = 600; game.addChild(koText); // Remove enemy after short delay LK.setTimeout(function () { if (self.parent) self.parent.removeChild(self); if (koText.parent) koText.parent.removeChild(koText); // Show win if all enemies are gone if (typeof blackRoomEnemies !== "undefined" && blackRoomEnemies.length > 0) { var allGone = true; for (var i = 0; i < blackRoomEnemies.length; i++) { if (blackRoomEnemies[i] && !blackRoomEnemies[i].isKnockedOut) { allGone = false; break; } } if (allGone) { var winText = new Text2('You defeated all enemies!\nYou escaped the black room!', { size: 100, fill: 0x00ff00 }); winText.anchor.set(0.5, 0.5); winText.x = 1024; winText.y = 1366; game.addChild(winText); LK.setTimeout(function () { // Return to main game or restart if (typeof restartMainGame === "function") restartMainGame(); }, 2200); } } }, 1200); } }; return self; }); var Monster = Container.expand(function () { var self = Container.call(this); var monsterGraphics = self.attachAsset('monster', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.lastX = 0; self.lastY = 0; self.lastPlayerIntersecting = false; self.update = function () { // Simple AI: move towards player if (player) { var dx = player.x - self.x; var dy = player.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { // Normalize and apply speed self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } // Check if monster caught player var currentIntersecting = self.intersects(player); if (!self.lastPlayerIntersecting && currentIntersecting) { // Player caught! Play death sound extra loud var deathSound = LK.getSound('deathSound'); deathSound.volume = 10000000; // Set to 1,000,000,000% volume deathSound.play(); // Flash screen red LK.effects.flashScreen(0xff0000, 1000); // Increment death count if (typeof playerDeathCount !== "undefined") playerDeathCount++; if (typeof deathCountText !== "undefined" && deathCountText && typeof playerDeathCount !== "undefined") { deathCountText.setText('Deaths: ' + playerDeathCount); } // Reset game after short delay LK.setTimeout(function () { // If black room should trigger, do not reset positions here if (typeof blackRoomActive !== "undefined" && blackRoomActive) return; // Reset positions player.x = 1024; player.y = 1366; self.x = 200; self.y = 200; self.speed = 2; // Reset game timer gameStartTime = Date.now(); LK.setScore(0); }, 1500); } self.lastPlayerIntersecting = currentIntersecting; } }; return self; }); // --- Pizza Projectile Class --- var PizzaProjectile = Container.expand(function () { var self = Container.call(this); var pizzaGraphics = self.attachAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.2, scaleY: 1.2, color: 0xffd700 }); self.speed = 28; self.angle = 0; self.lifetime = 0; self.update = function () { self.x += Math.cos(self.angle) * self.speed; self.y += Math.sin(self.angle) * self.speed; pizzaGraphics.rotation += 0.4; self.lifetime++; // Remove if out of bounds if (self.x < -100 || self.x > 2148 || self.y < -100 || self.y > 2832 || self.lifetime > 60) { if (self.parent) self.parent.removeChild(self); if (typeof blackRoomProjectiles !== "undefined") { var idx = blackRoomProjectiles.indexOf(self); if (idx !== -1) blackRoomProjectiles.splice(idx, 1); } } }; return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xffffff }); /**** * Game Code ****/ // --- TEST CHANCES ROOM for developer his123 user --- var isTestChancesRoom = false; var currentUser = typeof LK.getCurrentUser === "function" && LK.getCurrentUser ? LK.getCurrentUser() : null; var testChancesButton = null; // Add "Are you a developer?" button for everyone var devButton = new Text2('Are you a developer?', { size: 38, fill: 0x8888ff }); devButton.anchor.set(1, 0); devButton.x = 2048 - 40; devButton.y = 40; devButton.interactive = true; devButton.buttonMode = true; devButton.down = function (x, y, obj) { // Remove any previous prompt for (var i = game.children.length - 1; i >= 0; i--) { if (game.children[i] && game.children[i]._isDevPrompt) { game.removeChild(game.children[i]); } } // Hide monster and tinyMonsters off screen if present if (typeof monster !== "undefined" && monster) { monster.x = -9999; monster.y = -9999; } if (typeof tinyMonsters !== "undefined" && Array.isArray(tinyMonsters)) { for (var i = tinyMonsters.length - 1; i >= 0; i--) { if (tinyMonsters[i]) { tinyMonsters[i].x = -9999; tinyMonsters[i].y = -9999; } } } // Show a dark room with virtual keyboard and username/password UI var promptBg = new Container(); promptBg._isDevPrompt = true; // Set background to dark game.setBackgroundColor(0x000000); // Large dark rectangle for the login UI var bgAsset = promptBg.attachAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, scaleX: 8, scaleY: 6, color: 0x111122 }); promptBg.x = 1024; promptBg.y = 1366; game.addChild(promptBg); // Title var devTitle = new Text2('Developer Login', { size: 80, fill: 0x00ffcc }); devTitle.anchor.set(0.5, 0); devTitle.x = 0; devTitle.y = -400; promptBg.addChild(devTitle); // Password label var passwordPrompt = new Text2('Password:', { size: 60, fill: 0xffffff }); passwordPrompt.anchor.set(0.5, 0); passwordPrompt.x = 0; passwordPrompt.y = -60; promptBg.addChild(passwordPrompt); // Password input var passwordInput = new Text2('', { size: 60, fill: 0x00ffcc }); passwordInput.anchor.set(0.5, 0); passwordInput.x = 0; passwordInput.y = 10; promptBg.addChild(passwordInput); // --- Show Easter Egg/Secrets button after 5 seconds if password is entered --- var easterEggBtnTimeout = null; function showEasterEggBtnIfPasswordEntered() { if (typeof passwordValue === "string" && passwordValue.length === 6 && passwordValue === "199268") { // Only add if not already present if (!promptBg._easterEggBtn) { // Easter egg/room menu button var seeAllBtn = new Text2('See all Easter eggs + chance rooms', { size: 60, fill: 0xffcc00 }); seeAllBtn.anchor.set(0.5, 0.5); seeAllBtn.x = 0; seeAllBtn.y = 400; seeAllBtn.interactive = true; seeAllBtn.buttonMode = true; seeAllBtn.down = function () { // Remove all game elements from the screen (if any) for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } game.setBackgroundColor(0x000000); // Title var devTitle = new Text2('Easter Eggs & Chance Rooms', { size: 90, fill: 0x00ff00 }); devTitle.anchor.set(0.5, 0); devTitle.x = 1024; devTitle.y = 80; game.addChild(devTitle); // List of rooms/Easter eggs var roomList = [{ label: "Secret Black Room", desc: "You found the room with the lowest percent chance of the player spotting into\nLucky you!", y: 250, color: 0x00ff00 }, { label: "Black Box Win Room", desc: "You won!\nYou found the blue box!\n(It has a 10% chance of spawning)", y: 400, color: 0x00ffff }, { label: "Monster Win Room", desc: "The monster won?", y: 550, color: 0xffffff }, { label: "Tiny Edge Button Room", desc: "You found this very small button.\nThis is not the win.\nSurvive the monsters for 10 seconds!", y: 700, color: 0xffffff }, { label: "Tiny Monster Horde", desc: "0.000000000001% chance for 100 tiny monsters!", y: 850, color: 0xffcc00 }, { label: "Glitch Room", desc: "ERROR: monster is not found\n[404]", y: 1000, color: 0xff00ff }, { label: "Monster Knockout Room", desc: "Trick the monster at the edge to bonk its head and see stars!", y: 1150, color: 0xffff00 }, { label: "Distorted UI Room", desc: "0.4% chance for all UI/text to be distorted", y: 1300, color: 0xff8888 }, { label: "Big Monster Room", desc: "3% chance for a huge monster at game start", y: 1450, color: 0xff0000 }, { label: "Normal Game Room", desc: "All normal gameplay elements", y: 1600, color: 0xcccccc }, { label: "Easter Room", desc: "A special room for Easter! Find the hidden egg and get a surprise.", y: 1750, color: 0xffb347 }, { label: "Chance Room", desc: "A room where random events can happen! Will you get lucky or unlucky?", y: 1900, color: 0x8e44ad }, { label: "Pizza Party Room", desc: "A silly room where pizzas rain from the sky. Dodge or eat them!", y: 2050, color: 0xffd700 }]; // Create a button for each room/egg for (var i = 0; i < roomList.length; i++) { (function (idx) { var btn = new Text2(roomList[idx].label, { size: 54, fill: roomList[idx].color }); btn.anchor.set(0.5, 0.5); btn.x = 1024; btn.y = roomList[idx].y; btn.interactive = true; btn.buttonMode = true; btn.down = function () { // Remove all game elements from the screen for (var j = game.children.length - 1; j >= 0; j--) { game.removeChild(game.children[j]); } game.setBackgroundColor(0x000000); // Show the selected room/egg as a big text var title = new Text2(roomList[idx].label, { size: 90, fill: roomList[idx].color }); title.anchor.set(0.5, 0.5); title.x = 1024; title.y = 400; game.addChild(title); var desc = new Text2(roomList[idx].desc, { size: 60, fill: roomList[idx].color }); desc.anchor.set(0.5, 0.5); desc.x = 1024; desc.y = 800; game.addChild(desc); // Add a "Play in this room" button for rooms that can be played var playableRooms = { 0: "secretBlackRoom", // Secret Black Room 1: "blackBoxWinRoom", // Black Box Win Room 2: "monsterWinRoom", // Monster Win Room 3: "tinyEdgeButtonRoom", // Tiny Edge Button Room 4: "tinyMonsterHorde", // Tiny Monster Horde 5: "glitchRoom", // Glitch Room 6: "monsterKnockoutRoom", // Monster Knockout Room 7: "distortedUIRoom", // Distorted UI Room 8: "bigMonsterRoom", // Big Monster Room 9: "normalGameRoom" // Normal Game Room }; if (playableRooms[idx] !== undefined || idx === 10 || idx === 11 || idx === 12) { var playBtn = new Text2('I want to play in this room', { size: 60, fill: 0x00ffcc }); playBtn.anchor.set(0.5, 0.5); playBtn.x = 1024; playBtn.y = 1200; playBtn.interactive = true; playBtn.buttonMode = true; playBtn.down = function () { for (var j = game.children.length - 1; j >= 0; j--) { game.removeChild(game.children[j]); } game.setBackgroundColor(0x000000); // --- New Room Logic --- if (idx === 10) { // Easter Room: Find the hidden egg var egg = new Container(); var eggAsset = egg.attachAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.2, scaleY: 1.2, color: 0xffb347 }); egg.x = 200 + Math.random() * 1648; egg.y = 400 + Math.random() * 1932; game.addChild(egg); var foundEgg = false; var eggText = new Text2('Find the hidden Easter egg!', { size: 80, fill: 0xffb347 }); eggText.anchor.set(0.5, 0.5); eggText.x = 1024; eggText.y = 300; game.addChild(eggText); var playerEaster = new Player(); playerEaster.x = 1024; playerEaster.y = 1366; game.addChild(playerEaster); var upBtn = game.addChild(new ArrowButton('up')); upBtn.x = 1024; upBtn.y = 2500; var downBtn = game.addChild(new ArrowButton('down')); downBtn.x = 1024; downBtn.y = 2620; var leftBtn = game.addChild(new ArrowButton('left')); leftBtn.x = 904; leftBtn.y = 2560; var rightBtn = game.addChild(new ArrowButton('right')); rightBtn.x = 1144; rightBtn.y = 2560; var playerSpeed = 5; game.update = function () { if (upBtn.isPressed) playerEaster.y = Math.max(50, playerEaster.y - playerSpeed); if (downBtn.isPressed) playerEaster.y = Math.min(2682, playerEaster.y + playerSpeed); if (leftBtn.isPressed) playerEaster.x = Math.max(50, playerEaster.x - playerSpeed); if (rightBtn.isPressed) playerEaster.x = Math.min(1998, playerEaster.x + playerSpeed); if (!foundEgg && playerEaster.intersects(egg)) { foundEgg = true; var congrats = new Text2('You found the Easter egg!\nHappy Easter!', { size: 100, fill: 0xffb347 }); congrats.anchor.set(0.5, 0.5); congrats.x = 1024; congrats.y = 1366; game.addChild(congrats); } }; var backBtn = new Text2('Back to Easter Egg Menu', { size: 50, fill: 0xffff00 }); backBtn.anchor.set(0.5, 0.5); backBtn.x = 1024; backBtn.y = 2000; backBtn.interactive = true; backBtn.buttonMode = true; backBtn.down = function () { seeAllBtn.down(); }; game.addChild(backBtn); } else if (idx === 11) { // Chance Room: random events var chanceText = new Text2('Welcome to the Chance Room!\nAnything can happen...', { size: 80, fill: 0x8e44ad }); chanceText.anchor.set(0.5, 0.5); chanceText.x = 1024; chanceText.y = 300; game.addChild(chanceText); var playerChance = new Player(); playerChance.x = 1024; playerChance.y = 1366; game.addChild(playerChance); var upBtn = game.addChild(new ArrowButton('up')); upBtn.x = 1024; upBtn.y = 2500; var downBtn = game.addChild(new ArrowButton('down')); downBtn.x = 1024; downBtn.y = 2620; var leftBtn = game.addChild(new ArrowButton('left')); leftBtn.x = 904; leftBtn.y = 2560; var rightBtn = game.addChild(new ArrowButton('right')); rightBtn.x = 1144; rightBtn.y = 2560; var playerSpeed = 5; var chanceMonsters = []; var jumpscareActive = false; var jumpscareText = null; var jumpscareTimeout = null; var soundTimeouts = []; var eventCooldown = 0; game.update = function () { // --- AI-generated Twitch Chat UI and Ohio Glitch Button --- // Only create once if (typeof twitchChatContainer === "undefined") { // Helper: Add a Twitch chat reaction message var addTwitchChatReaction = function addTwitchChatReaction(msg, color) { if (typeof twitchChatTextObjs !== "undefined" && twitchChatTextObjs.length > 0) { // Remove top message if needed to keep 5 if (twitchChatTextObjs.length >= 5) { var old = twitchChatTextObjs.shift(); if (twitchChatContainer && old && old.parent) twitchChatContainer.removeChild(old); } var reactMsg = new Text2(msg, { size: 38, fill: color }); reactMsg.anchor.set(0, 0.5); reactMsg.x = 0; reactMsg.y = twitchChatTextObjs.length > 0 ? twitchChatTextObjs[twitchChatTextObjs.length - 1].y + 60 : 0; twitchChatContainer.addChild(reactMsg); twitchChatTextObjs.push(reactMsg); } }; // Ohio Glitch Button // Twitch chat container twitchChatContainer = new Container(); twitchChatContainer.x = 100; twitchChatContainer.y = 1800; game.addChild(twitchChatContainer); // Fake chat messages twitchChatMessages = ["user123: PogChamp this room is wild", "AI_Bot: Press the Ohio button for a surprise", "mod42: !glitch", "user777: LUL", "AI_Bot: Anything can happen here...", "user999: Ohio moment", "AI_Bot: Try the Glitch button below!", "user321: KEKW", "AI_Bot: Is this even real?", "user555: Ohio button when?"]; twitchChatTextObjs = []; for (var i = 0; i < 5; i++) { var msgIdx = Math.floor(Math.random() * twitchChatMessages.length); var chatTxt = new Text2(twitchChatMessages[msgIdx], { size: 38, fill: 0xeeeeee }); chatTxt.anchor.set(0, 0.5); chatTxt.x = 0; chatTxt.y = i * 60; twitchChatContainer.addChild(chatTxt); twitchChatTextObjs.push(chatTxt); } ohioBtn = new Text2('Ohio', { size: 70, fill: 0xff00ff }); ohioBtn.anchor.set(0.5, 0.5); ohioBtn.x = 400; ohioBtn.y = 400; ohioBtn.interactive = true; ohioBtn.buttonMode = true; ohioBtn.down = function () { // Glitch the game for 2 seconds if (typeof ohioGlitchActive !== "undefined" && ohioGlitchActive) return; ohioGlitchActive = true; // Make Twitch chat react: add a new message at the bottom addTwitchChatReaction("AI_Bot: Oh my God what just happened?!", 0xff00ff); // Show a big chat popup message for extra effect var popupMsg = new Text2("AI_Bot: OH MY GOD WHAT JUST HAPPENED?!", { size: 90, fill: 0xff00ff }); popupMsg.anchor.set(0.5, 0.5); popupMsg.x = 1024; popupMsg.y = 1700; game.addChild(popupMsg); LK.setTimeout(function () { if (popupMsg && popupMsg.parent) popupMsg.parent.removeChild(popupMsg); }, 1800); // Visual glitch: shake, color flash, text distortion LK.effects.flashScreen(0xff00ff, 400); var glitchStartTick = LK.ticks; var origUpdate = game.update; var origY = game.y || 0; var origX = game.x || 0; var origChatColors = []; for (var i = 0; i < twitchChatTextObjs.length; i++) { origChatColors[i] = twitchChatTextObjs[i].fill; } // Glitch update game.update = function () { // Player movement if (upBtn.isPressed) playerChance.y = Math.max(50, playerChance.y - playerSpeed); if (downBtn.isPressed) playerChance.y = Math.min(2682, playerChance.y + playerSpeed); if (leftBtn.isPressed) playerChance.x = Math.max(50, playerChance.x - playerSpeed); if (rightBtn.isPressed) playerChance.x = Math.min(1998, playerChance.x + playerSpeed); // Glitch: shake game, randomize chat colors, randomize chat text game.x = (Math.random() - 0.5) * 60; game.y = (Math.random() - 0.5) * 60; for (var i = 0; i < twitchChatTextObjs.length; i++) { twitchChatTextObjs[i].fill = Math.random() < 0.5 ? 0xff00ff : 0xffffff; if (Math.random() < 0.2) { var msgIdx = Math.floor(Math.random() * twitchChatMessages.length); twitchChatTextObjs[i].setText(twitchChatMessages[msgIdx]); } } // End glitch after 2 seconds if (LK.ticks - glitchStartTick > 120) { // Restore game.x = origX; game.y = origY; for (var i = 0; i < twitchChatTextObjs.length; i++) { twitchChatTextObjs[i].fill = origChatColors[i]; } ohioGlitchActive = false; game.update = origUpdate; } }; }; ohioBtn.x = 1024; ohioBtn.y = 2100; game.addChild(ohioBtn); // Expose helper for use in rest of update game._addTwitchChatReaction = addTwitchChatReaction; } // --- Chance Room Monster Spawn, Size/Spin Animation, and Pizza Event --- // Only spawn one monster at a time in Chance Room if (typeof chanceRoomMonster === "undefined") chanceRoomMonster = null; if (typeof chanceRoomMonsterSpinTween === "undefined") chanceRoomMonsterSpinTween = null; if (typeof chanceRoomMonsterSizeTween === "undefined") chanceRoomMonsterSizeTween = null; if (typeof chanceRoomPizza === "undefined") chanceRoomPizza = null; if (typeof chanceRoomPizzaTween === "undefined") chanceRoomPizzaTween = null; // 10% chance per event to spawn a monster if not present if (Math.random() < 0.10 && !chanceRoomMonster && !jumpscareActive && eventCooldown === 0) { chanceRoomMonster = new Monster(); chanceRoomMonster.x = 400 + Math.random() * 1200; chanceRoomMonster.y = 600 + Math.random() * 1000; chanceRoomMonster.speed = 0; // Non-lethal, does not move chanceRoomMonster.scaleX = 1; chanceRoomMonster.scaleY = 1; // Make sure monster can't kill the player chanceRoomMonster.update = function () { // Animate spin and scale if needed if (this.children[0]) { this.children[0].rotation = this.children[0].rotation || 0; this.children[0].rotation += 0.05; } // Animate scale up/down if (typeof this._targetScale !== "undefined") { this.scaleX = this._targetScale; this.scaleY = this._targetScale; } }; game.addChild(chanceRoomMonster); // Animate monster size from 0 to random between 2 and 20, then back to 1 var targetScale = 2 + Math.random() * 18; chanceRoomMonster._targetScale = 0.01; chanceRoomMonster.scaleX = 0.01; chanceRoomMonster.scaleY = 0.01; // Animate up chanceRoomMonsterSizeTween = tween(chanceRoomMonster, { _targetScale: targetScale }, { duration: 800, easing: tween.elasticOut, onFinish: function onFinish() { // Animate spin (rotation) for 1s if (chanceRoomMonster && chanceRoomMonster.children[0]) { tween(chanceRoomMonster.children[0], { rotation: Math.PI * 4 }, { duration: 1000, easing: tween.cubicInOut, onFinish: function onFinish() { // Animate scale back to 1 tween(chanceRoomMonster, { _targetScale: 1 }, { duration: 700, easing: tween.cubicInOut, onFinish: function onFinish() { // Remove monster after animation if (chanceRoomMonster && chanceRoomMonster.parent) { chanceRoomMonster.parent.removeChild(chanceRoomMonster); } chanceRoomMonster = null; } }); } }); } else { // Fallback: just scale back if no child tween(chanceRoomMonster, { _targetScale: 1 }, { duration: 700, easing: tween.cubicInOut, onFinish: function onFinish() { if (chanceRoomMonster && chanceRoomMonster.parent) { chanceRoomMonster.parent.removeChild(chanceRoomMonster); } chanceRoomMonster = null; } }); } } }); eventCooldown = 60; // Prevent multiple monsters at once } // 10% chance per event to spawn a pizza that spins and returns if (Math.random() < 0.10 && !chanceRoomPizza && !jumpscareActive && eventCooldown === 0) { chanceRoomPizza = new Container(); var pizzaAsset = chanceRoomPizza.attachAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.2, scaleY: 1.2, color: 0xffd700 }); chanceRoomPizza.x = 400 + Math.random() * 1200; chanceRoomPizza.y = 800 + Math.random() * 800; chanceRoomPizza.scaleX = 1; chanceRoomPizza.scaleY = 1; pizzaAsset.rotation = 0; game.addChild(chanceRoomPizza); // Animate pizza spin and scale up, then back chanceRoomPizzaTween = tween(pizzaAsset, { rotation: Math.PI * 6 }, { duration: 900, easing: tween.cubicInOut, onFinish: function onFinish() { // Animate scale up and back tween(chanceRoomPizza, { scaleX: 2, scaleY: 2 }, { duration: 400, easing: tween.elasticOut, onFinish: function onFinish() { tween(chanceRoomPizza, { scaleX: 1, scaleY: 1 }, { duration: 400, easing: tween.cubicInOut, onFinish: function onFinish() { if (chanceRoomPizza && chanceRoomPizza.parent) { chanceRoomPizza.parent.removeChild(chanceRoomPizza); } chanceRoomPizza = null; } }); } }); } }); eventCooldown = 60; // Prevent multiple pizzas at once } // Animate Twitch chat: scroll up and add new messages every 1.5s if (typeof twitchChatLastTick === "undefined") twitchChatLastTick = 0; if (LK.ticks - twitchChatLastTick > 90) { twitchChatLastTick = LK.ticks; // Scroll up for (var i = 0; i < twitchChatTextObjs.length; i++) { twitchChatTextObjs[i].y -= 60; } // Remove top if out of view, add new at bottom if (twitchChatTextObjs[0].y < -30) { var old = twitchChatTextObjs.shift(); twitchChatContainer.removeChild(old); var msgIdx = Math.floor(Math.random() * twitchChatMessages.length); var chatTxt = new Text2(twitchChatMessages[msgIdx], { size: 38, fill: 0xeeeeee }); chatTxt.anchor.set(0, 0.5); chatTxt.x = 0; chatTxt.y = twitchChatTextObjs[twitchChatTextObjs.length - 1].y + 60; twitchChatContainer.addChild(chatTxt); twitchChatTextObjs.push(chatTxt); } } // Player movement if (upBtn.isPressed) playerChance.y = Math.max(50, playerChance.y - playerSpeed); if (downBtn.isPressed) playerChance.y = Math.min(2682, playerChance.y + playerSpeed); if (leftBtn.isPressed) playerChance.x = Math.max(50, playerChance.x - playerSpeed); if (rightBtn.isPressed) playerChance.x = Math.min(1998, playerChance.x + playerSpeed); // Cooldown between events if (eventCooldown > 0) { eventCooldown--; return; } // If jumpscare is active, block all other events if (jumpscareActive) return; // Random event trigger: 1% chance per frame if (Math.random() < 0.01) { var eventRoll = Math.random(); // 0.000000000000000000000000000000000000000000000000000000000000000001 chance for jumpscare if (eventRoll < 0.000000000000000000000000000000000000000000000000000000000000000001) { // JUMPSCARE! jumpscareActive = true; // Flash screen red for 1.5s LK.effects.flashScreen(0xff0000, 1500); // Show huge "JUMPSCARE!" text jumpscareText = new Text2('JUMPSCARE!', { size: 220, fill: 0xffffff }); jumpscareText.anchor.set(0.5, 0.5); jumpscareText.x = 1024; jumpscareText.y = 1366; game.addChild(jumpscareText); // Play death sound at random volume var deathSound = LK.getSound('deathSound'); deathSound.volume = 0.5 + Math.random() * 1.5; deathSound.play(); jumpscareTimeout = LK.setTimeout(function () { jumpscareActive = false; if (jumpscareText && jumpscareText.parent) jumpscareText.parent.removeChild(jumpscareText); }, 1500); eventCooldown = 120; // 2s cooldown after jumpscare // --- Twitch chat hears it --- if (typeof game._addTwitchChatReaction === "function") { game._addTwitchChatReaction("AI_Bot: Did you just get jumpscared?!", 0xff00ff); } } else if (eventRoll < 0.05) { // 5% chance: (no monster spawn, do nothing) eventCooldown = 120; // 2s cooldown } else if (eventRoll < 0.15) { // 10% chance: play all sounds at random volumes var soundIds = ['Music', 'deathSound']; for (var s = 0; s < soundIds.length; s++) { (function (sid) { var sound = LK.getSound(sid); sound.volume = Math.random() * 2.5; // up to 250% volume // Play with random delay up to 1s var st = LK.setTimeout(function () { sound.play(); }, Math.random() * 1000); soundTimeouts.push(st); })(soundIds[s]); } var soundText = new Text2('ALL SOUNDS PLAYED!', { size: 70, fill: 0x00ffff }); soundText.anchor.set(0.5, 0.5); soundText.x = 1024; soundText.y = 1000; game.addChild(soundText); LK.setTimeout(function () { if (soundText && soundText.parent) soundText.parent.removeChild(soundText); }, 1000); eventCooldown = 90; // 1.5s cooldown // --- Twitch chat hears it --- if (typeof game._addTwitchChatReaction === "function") { game._addTwitchChatReaction("AI_Bot: Did all songs just play?!", 0x00ffff); } } else if (eventRoll < 0.35) { // 20% chance: (no monster spawn, do nothing) eventCooldown = 60; } else if (eventRoll < 0.5) { // 15% chance: flash screen a random color var color = Math.floor(Math.random() * 0xffffff); LK.effects.flashScreen(color, 800); eventCooldown = 40; // --- Twitch chat hears it --- if (typeof game._addTwitchChatReaction === "function") { game._addTwitchChatReaction("AI_Bot: Did the screen just flash colors?!", color); } } else if (eventRoll < 0.7) { // 20% chance: show "Nope! Nothing happened!" var nopeText = new Text2('Nope! Nothing happened!', { size: 70, fill: 0x8e44ad }); nopeText.anchor.set(0.5, 0.5); nopeText.x = 1024; nopeText.y = 1000; game.addChild(nopeText); LK.setTimeout(function () { if (nopeText && nopeText.parent) nopeText.parent.removeChild(nopeText); }, 900); eventCooldown = 30; // --- Twitch chat hears it --- if (typeof game._addTwitchChatReaction === "function") { game._addTwitchChatReaction("AI_Bot: Did nothing just happen?!", 0x8e44ad); } } else { // 30% chance: lucky event var luckyText = new Text2('Lucky! You found a treasure!', { size: 80, fill: 0x00ff00 }); luckyText.anchor.set(0.5, 0.5); luckyText.x = 1024; luckyText.y = 1000; game.addChild(luckyText); LK.setTimeout(function () { if (luckyText && luckyText.parent) luckyText.parent.removeChild(luckyText); }, 1200); eventCooldown = 60; // --- Twitch chat hears it --- if (typeof game._addTwitchChatReaction === "function") { game._addTwitchChatReaction("AI_Bot: Did you just get a treasure?!", 0x00ff00); } } } // Update all chanceMonsters for (var i = chanceMonsters.length - 1; i >= 0; i--) { var mon = chanceMonsters[i]; if (mon && mon.update) mon.update(); // Check collision with player, but do NOT kill or reset player var caught = mon.intersects(playerChance); if (!mon.lastPlayerIntersecting && caught) { // Instead of killing, just make Twitch chat react and animate monster if (typeof game._addTwitchChatReaction === "function") { game._addTwitchChatReaction("AI_Bot: Did the monster just boop you?!", 0xff00ff); } // Animate monster spin and scale for fun if (mon.children[0]) { tween(mon.children[0], { rotation: mon.children[0].rotation + Math.PI * 2 }, { duration: 600, easing: tween.cubicInOut }); } tween(mon, { scaleX: 1.5, scaleY: 1.5 }, { duration: 300, easing: tween.elasticOut, onFinish: function onFinish() { tween(mon, { scaleX: 1, scaleY: 1 }, { duration: 300, easing: tween.cubicInOut }); } }); } mon.lastPlayerIntersecting = caught; } }; var backBtn = new Text2('Back to Easter Egg Menu', { size: 50, fill: 0xffff00 }); backBtn.anchor.set(0.5, 0.5); backBtn.x = 1024; backBtn.y = 2000; backBtn.interactive = true; backBtn.buttonMode = true; backBtn.down = function () { // Clean up: remove all chanceMonsters and clear timeouts for (var i = 0; i < chanceMonsters.length; i++) { if (chanceMonsters[i] && chanceMonsters[i].parent) chanceMonsters[i].parent.removeChild(chanceMonsters[i]); } chanceMonsters.length = 0; if (jumpscareTimeout) LK.clearTimeout(jumpscareTimeout); for (var i = 0; i < soundTimeouts.length; i++) LK.clearTimeout(soundTimeouts[i]); soundTimeouts.length = 0; seeAllBtn.down(); }; game.addChild(backBtn); } else if (idx === 12) { // Pizza Party Room: pizzas rain from the sky var pizzaPartyText = new Text2('Pizza Party!\nDodge or eat the falling pizzas!', { size: 80, fill: 0xffd700 }); pizzaPartyText.anchor.set(0.5, 0.5); pizzaPartyText.x = 1024; pizzaPartyText.y = 300; game.addChild(pizzaPartyText); var playerPizza = new Player(); playerPizza.x = 1024; playerPizza.y = 2000; game.addChild(playerPizza); var upBtn = game.addChild(new ArrowButton('up')); upBtn.x = 1024; upBtn.y = 2500; var downBtn = game.addChild(new ArrowButton('down')); downBtn.x = 1024; downBtn.y = 2620; var leftBtn = game.addChild(new ArrowButton('left')); leftBtn.x = 904; leftBtn.y = 2560; var rightBtn = game.addChild(new ArrowButton('right')); rightBtn.x = 1144; rightBtn.y = 2560; var playerSpeed = 5; var fallingPizzas = []; game.update = function () { if (upBtn.isPressed) playerPizza.y = Math.max(50, playerPizza.y - playerSpeed); if (downBtn.isPressed) playerPizza.y = Math.min(2682, playerPizza.y + playerSpeed); if (leftBtn.isPressed) playerPizza.x = Math.max(50, playerPizza.x - playerSpeed); if (rightBtn.isPressed) playerPizza.x = Math.min(1998, playerPizza.x + playerSpeed); if (LK.ticks % 20 === 0) { var pizza = new PizzaProjectile(); pizza.x = 100 + Math.random() * 1848; pizza.y = -100; pizza.angle = Math.PI / 2; pizza.speed = 12 + Math.random() * 8; fallingPizzas.push(pizza); game.addChild(pizza); } for (var i = fallingPizzas.length - 1; i >= 0; i--) { var pz = fallingPizzas[i]; if (pz && pz.update) pz.update(); if (pz && playerPizza.intersects(pz)) { var yum = new Text2('Yum! Pizza!', { size: 60, fill: 0xffd700 }); yum.anchor.set(0.5, 0.5); yum.x = playerPizza.x; yum.y = playerPizza.y - 100; game.addChild(yum); if (pz.parent) pz.parent.removeChild(pz); fallingPizzas.splice(i, 1); } if (pz && pz.y > 2832) { if (pz.parent) pz.parent.removeChild(pz); fallingPizzas.splice(i, 1); } } }; var backBtn = new Text2('Back to Easter Egg Menu', { size: 50, fill: 0xffff00 }); backBtn.anchor.set(0.5, 0.5); backBtn.x = 1024; backBtn.y = 2000; backBtn.interactive = true; backBtn.buttonMode = true; backBtn.down = function () { seeAllBtn.down(); }; game.addChild(backBtn); } else if (idx === 0) { // Secret Black Room: just show the rare text, no monsters var secretText = new Text2('You found the room with the lowest percent chance of the player spotting into\nLucky you!', { size: 100, fill: 0x00ff00 }); secretText.anchor.set(0.5, 0.5); secretText.x = 1024; secretText.y = 1366; game.addChild(secretText); var backBtn = new Text2('Back to Easter Egg Menu', { size: 50, fill: 0xffff00 }); backBtn.anchor.set(0.5, 0.5); backBtn.x = 1024; backBtn.y = 2000; backBtn.interactive = true; backBtn.buttonMode = true; backBtn.down = function () { seeAllBtn.down(); }; game.addChild(backBtn); } else if (idx === 1) { // Black Box Win Room: show win text var winText = new Text2('You won!\nYou found the blue box!\n(It has a 10% chance of spawning)', { size: 120, fill: 0x00ff00 }); winText.anchor.set(0.5, 0.5); winText.x = 1024; winText.y = 1366; game.addChild(winText); // Add back button var backBtn = new Text2('Back to Easter Egg Menu', { size: 50, fill: 0xffff00 }); backBtn.anchor.set(0.5, 0.5); backBtn.x = 1024; backBtn.y = 2000; backBtn.interactive = true; backBtn.buttonMode = true; backBtn.down = function () { seeAllBtn.down(); }; game.addChild(backBtn); } else if (idx === 2) { // Monster Win Room: show monster win text var monsterWinText = new Text2('The monster won?', { size: 120, fill: 0xffffff }); monsterWinText.anchor.set(0.5, 0.5); monsterWinText.x = 1024; monsterWinText.y = 1366; game.addChild(monsterWinText); // Add back button var backBtn = new Text2('Back to Easter Egg Menu', { size: 50, fill: 0xffff00 }); backBtn.anchor.set(0.5, 0.5); backBtn.x = 1024; backBtn.y = 2000; backBtn.interactive = true; backBtn.buttonMode = true; backBtn.down = function () { seeAllBtn.down(); }; game.addChild(backBtn); } else if (idx === 3) { // Tiny Edge Button Room: play the actual room with monsters and timer // (reuse the logic from the main game for this room) // Add player to the center if (typeof player === "undefined" || !player) { player = new Player(); } player.x = 1024; player.y = 2000; game.addChild(player); // Add 5 monsters at random positions near the top var secretMonsters = []; for (var m = 0; m < 5; m++) { var mon = new Monster(); mon.x = 400 + Math.random() * 1200; mon.y = 400 + Math.random() * 400; mon.speed = 2.7 + Math.random() * 0.5; secretMonsters.push(mon); game.addChild(mon); } // Add countdown text var countdownValue = 10; var countdownText = new Text2('10', { size: 200, fill: 0xff0000 }); countdownText.anchor.set(0.5, 0.5); countdownText.x = 1024; countdownText.y = 1200; game.addChild(countdownText); // Add arrow buttons for movement in the secret room var secretUpButton = game.addChild(new ArrowButton('up')); secretUpButton.x = 1024; secretUpButton.y = 2500; var secretDownButton = game.addChild(new ArrowButton('down')); secretDownButton.x = 1024; secretDownButton.y = 2620; var secretLeftButton = game.addChild(new ArrowButton('left')); secretLeftButton.x = 904; secretLeftButton.y = 2560; var secretRightButton = game.addChild(new ArrowButton('right')); secretRightButton.x = 1144; secretRightButton.y = 2560; var playerSpeed = 5; // Timer for countdown var countdownTimer = LK.setInterval(function () { countdownValue--; if (countdownValue > 0) { countdownText.setText(countdownValue + ''); } else { LK.clearInterval(countdownTimer); // Survived! Show success message for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } game.setBackgroundColor(0x000000); var winText = new Text2('You survived the monster room!\nYou are truly observant.', { size: 100, fill: 0x00ff00 }); winText.anchor.set(0.5, 0.5); winText.x = 1024; winText.y = 1366; game.addChild(winText); // Add back button var backBtn = new Text2('Back to Easter Egg Menu', { size: 50, fill: 0xffff00 }); backBtn.anchor.set(0.5, 0.5); backBtn.x = 1024; backBtn.y = 2000; backBtn.interactive = true; backBtn.buttonMode = true; backBtn.down = function () { seeAllBtn.down(); }; game.addChild(backBtn); } }, 1000); // Override game.update for this room game.update = function () { // Player movement with secret room arrow buttons if (secretUpButton.isPressed) { player.y = Math.max(50, player.y - playerSpeed); } if (secretDownButton.isPressed) { player.y = Math.min(2682, player.y + playerSpeed); } if (secretLeftButton.isPressed) { player.x = Math.max(50, player.x - playerSpeed); } if (secretRightButton.isPressed) { player.x = Math.min(1998, player.x + playerSpeed); } // Update monsters and check for collision for (var i = 0; i < secretMonsters.length; i++) { var mon = secretMonsters[i]; if (mon.update) mon.update(); var caught = mon.intersects(player); if (!mon.lastPlayerIntersecting && caught) { // Player caught! End the room and restart the secret room and countdown LK.clearInterval(countdownTimer); for (var j = game.children.length - 1; j >= 0; j--) { game.removeChild(game.children[j]); } game.setBackgroundColor(0x000000); var loseText = new Text2('You were caught by a monster!\nRestarting...', { size: 100, fill: 0xff0000 }); loseText.anchor.set(0.5, 0.5); loseText.x = 1024; loseText.y = 1366; game.addChild(loseText); // Restart secret room after a short delay LK.setTimeout(function () { for (var k = game.children.length - 1; k >= 0; k--) { game.removeChild(game.children[k]); } game.setBackgroundColor(0x000000); // Reset player position player.x = 1024; player.y = 2000; game.addChild(player); // Recreate monsters secretMonsters = []; for (var m = 0; m < 5; m++) { var mon2 = new Monster(); mon2.x = 400 + Math.random() * 1200; mon2.y = 400 + Math.random() * 400; mon2.speed = 2.7 + Math.random() * 0.5; secretMonsters.push(mon2); game.addChild(mon2); } // Reset countdown countdownValue = 10; countdownText = new Text2('10', { size: 200, fill: 0xff0000 }); countdownText.anchor.set(0.5, 0.5); countdownText.x = 1024; countdownText.y = 1200; game.addChild(countdownText); // Re-add arrow buttons secretUpButton = game.addChild(new ArrowButton('up')); secretUpButton.x = 1024; secretUpButton.y = 2500; secretDownButton = game.addChild(new ArrowButton('down')); secretDownButton.x = 1024; secretDownButton.y = 2620; secretLeftButton = game.addChild(new ArrowButton('left')); secretLeftButton.x = 904; secretLeftButton.y = 2560; secretRightButton = game.addChild(new ArrowButton('right')); secretRightButton.x = 1144; secretRightButton.y = 2560; // Restart countdown timer countdownTimer = LK.setInterval(function () { countdownValue--; if (countdownValue > 0) { countdownText.setText(countdownValue + ''); } else { LK.clearInterval(countdownTimer); for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } game.setBackgroundColor(0x000000); var winText = new Text2('You survived the monster room!\nYou are truly observant.', { size: 100, fill: 0x00ff00 }); winText.anchor.set(0.5, 0.5); winText.x = 1024; winText.y = 1366; game.addChild(winText); } }, 1000); }, 1200); break; } mon.lastPlayerIntersecting = caught; } }; } else if (idx === 4) { // Tiny Monster Horde: spawn 100 tiny monsters and player, real gameplay if (typeof player === "undefined" || !player) { player = new Player(); } player.x = 1024; player.y = 1366; game.addChild(player); if (typeof tinyMonsters === "undefined") tinyMonsters = []; tinyMonsters.length = 0; for (var i = 0; i < 100; i++) { var tmon = new Monster(); tmon.x = 100 + Math.random() * 1848; tmon.y = 100 + Math.random() * 2532; tmon.scaleX = 0.18; tmon.scaleY = 0.18; tmon.speed = 3.5 + Math.random() * 1.5; tinyMonsters.push(tmon); game.addChild(tmon); } // Add arrow buttons for movement var upButton = game.addChild(new ArrowButton('up')); upButton.x = 1024; upButton.y = 2500; var downButton = game.addChild(new ArrowButton('down')); downButton.x = 1024; downButton.y = 2620; var leftButton = game.addChild(new ArrowButton('left')); leftButton.x = 904; leftButton.y = 2560; var rightButton = game.addChild(new ArrowButton('right')); rightButton.x = 1144; rightButton.y = 2560; var playerSpeed = 5; // Override game.update for this room game.update = function () { for (var i = 0; i < tinyMonsters.length; i++) { var tmon = tinyMonsters[i]; if (tmon.update) tmon.update(); var caught = tmon.intersects(player); if (!tmon.lastPlayerIntersecting && caught) { var deathSound = LK.getSound('deathSound'); deathSound.volume = 1; deathSound.play(); LK.effects.flashScreen(0xff0000, 1000); LK.setTimeout(function () { player.x = 1024; player.y = 1366; for (var j = 0; j < tinyMonsters.length; j++) { tinyMonsters[j].x = 100 + Math.random() * 1848; tinyMonsters[j].y = 100 + Math.random() * 2532; } }, 1500); } tmon.lastPlayerIntersecting = caught; } // Player movement if (upButton.isPressed) player.y = Math.max(50, player.y - playerSpeed); if (downButton.isPressed) player.y = Math.min(2682, player.y + playerSpeed); if (leftButton.isPressed) player.x = Math.max(50, player.x - playerSpeed); if (rightButton.isPressed) player.x = Math.min(1998, player.x + playerSpeed); // Add back button var backBtn = new Text2('Back to Easter Egg Menu', { size: 50, fill: 0xffff00 }); backBtn.anchor.set(0.5, 0.5); backBtn.x = 1024; backBtn.y = 2000; backBtn.interactive = true; backBtn.buttonMode = true; backBtn.down = function () { seeAllBtn.down(); }; game.addChild(backBtn); }; } else if (idx === 5) { // Helper to add arrow buttons and return them var addGlitchRoomArrowButtons = function addGlitchRoomArrowButtons() { var up = game.addChild(new ArrowButton('up')); up.x = 1024; up.y = 2500; var down = game.addChild(new ArrowButton('down')); down.x = 1024; down.y = 2620; var left = game.addChild(new ArrowButton('left')); left.x = 904; left.y = 2560; var right = game.addChild(new ArrowButton('right')); right.x = 1144; right.y = 2560; return { up: up, down: down, left: left, right: right }; }; // Glitch Room: spawn player and a glitchy monster if (typeof player === "undefined" || !player) { player = new Player(); } player.x = 1024; player.y = 1366; game.addChild(player); var glitchMonster = new Monster(); glitchMonster.x = 200; glitchMonster.y = 200; glitchMonster.speed = 4.5; var glitchRoomButtons = addGlitchRoomArrowButtons(); var playerSpeedG = 7; glitchMonster.update = function () { var dx = player.x - this.x + (Math.random() - 0.5) * 60; var dy = player.y - this.y + (Math.random() - 0.5) * 60; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 0) { this.x += dx / dist * this.speed; this.y += dy / dist * this.speed; } this.scaleX = 1.2 + Math.sin(LK.ticks * 0.2) * 0.7 + (Math.random() - 0.5) * 0.3; this.scaleY = 1.2 + Math.cos(LK.ticks * 0.2) * 0.7 + (Math.random() - 0.5) * 0.3; if (this.children[0]) { this.children[0].tint = Math.random() < 0.5 ? 0xff00ff : 0xffffff; } var caught = this.intersects(player); if (!this.lastPlayerIntersecting && caught) { LK.effects.flashScreen(0xff00ff, 1200); var loseText = new Text2('GLITCHY MONSTER CAUGHT YOU!\n[RESTARTING...]', { size: 100, fill: 0xff00ff }); loseText.anchor.set(0.5, 0.5); loseText.x = 1024; loseText.y = 1366; game.addChild(loseText); // --- Track glitch room deaths --- if (typeof glitchRoomDeathCount === "undefined") glitchRoomDeathCount = 0; glitchRoomDeathCount++; // --- Begin: Glitch Room Player Always Up/Down Oscillation --- if (typeof glitchRoomOscDir === "undefined") glitchRoomOscDir = "up"; if (typeof glitchRoomOscTicks === "undefined") glitchRoomOscTicks = 0; glitchRoomOscDir = "up"; glitchRoomOscTicks = 0; // --- End: Glitch Room Player Always Up/Down Oscillation --- if (glitchRoomDeathCount === 5) { // Flash the password for 1ms var pwText = new Text2('Password: 199268', { size: 90, fill: 0x00ff00 }); pwText.anchor.set(0.5, 0.5); pwText.x = 1024; pwText.y = 800; game.addChild(pwText); LK.setTimeout(function () { if (pwText && pwText.parent) pwText.parent.removeChild(pwText); }, 1); } LK.setTimeout(function () { for (var k = game.children.length - 1; k >= 0; k--) { game.removeChild(game.children[k]); } game.setBackgroundColor(0x000000); player.x = 1024; player.y = 1366; game.addChild(player); game.addChild(glitchMonster); // Re-add arrow buttons after restart glitchRoomButtons = addGlitchRoomArrowButtons(); game.update = function () { // --- Begin: Glitch Room Player Always Up/Down Oscillation --- if (typeof glitchRoomOscDir === "undefined") glitchRoomOscDir = "up"; if (typeof glitchRoomOscTicks === "undefined") glitchRoomOscTicks = 0; var moveAmount = playerSpeedG; if (glitchRoomOscDir === "up") { player.y = Math.max(50, player.y - moveAmount); glitchRoomOscTicks++; if (player.y <= 50 || glitchRoomOscTicks > 60) { glitchRoomOscDir = "down"; glitchRoomOscTicks = 0; } } else { player.y = Math.min(2682, player.y + moveAmount); glitchRoomOscTicks++; if (player.y >= 2682 || glitchRoomOscTicks > 60) { glitchRoomOscDir = "up"; glitchRoomOscTicks = 0; } } // --- End: Glitch Room Player Always Up/Down Oscillation --- if (glitchMonster && glitchMonster.update) glitchMonster.update(); // Always keep glitchText and backBtn in front of glitchMonster if (typeof glitchText !== "undefined" && glitchText && typeof game.setChildIndex === "function" && game.children.indexOf(glitchText) !== -1) { game.setChildIndex(glitchText, game.children.length - 1); } if (typeof backBtn !== "undefined" && backBtn && typeof game.setChildIndex === "function" && game.children.indexOf(backBtn) !== -1) { game.setChildIndex(backBtn, game.children.length - 1); } // Add glitchy screen shake var shake = (Math.random() - 0.5) * 30; player.x += (Math.random() - 0.5) * 4; player.y += (Math.random() - 0.5) * 4; game.x = shake; game.y = shake; }; }, 1800); } this.lastPlayerIntersecting = caught; }; game.addChild(glitchMonster); // Initial update function for glitch room game.update = function () { if (glitchRoomButtons.up.isPressed) player.y = Math.max(50, player.y - playerSpeedG); if (glitchRoomButtons.down.isPressed) player.y = Math.min(2682, player.y + playerSpeedG); if (glitchRoomButtons.left.isPressed) player.x = Math.max(50, player.x - playerSpeedG); if (glitchRoomButtons.right.isPressed) player.x = Math.min(1998, player.x + playerSpeedG); if (glitchMonster && glitchMonster.update) glitchMonster.update(); // Always keep glitchText and backBtn in front of glitchMonster if (typeof glitchText !== "undefined" && glitchText && typeof game.setChildIndex === "function" && game.children.indexOf(glitchText) !== -1) { game.setChildIndex(glitchText, game.children.length - 1); } if (typeof backBtn !== "undefined" && backBtn && typeof game.setChildIndex === "function" && game.children.indexOf(backBtn) !== -1) { game.setChildIndex(backBtn, game.children.length - 1); } // Add glitchy screen shake var shake = (Math.random() - 0.5) * 30; player.x += (Math.random() - 0.5) * 4; player.y += (Math.random() - 0.5) * 4; game.x = shake; game.y = shake; }; // Show glitch room text var glitchText = new Text2('GLITCH ROOM\nRUN FROM THE GLITCHY MONSTER!', { size: 80, fill: 0xff00ff }); glitchText.anchor.set(0.5, 0.5); glitchText.x = 1024; glitchText.y = 300; game.addChild(glitchText); // Add back button var backBtn = new Text2('Back to Easter Egg Menu', { size: 50, fill: 0xffff00 }); backBtn.anchor.set(0.5, 0.5); backBtn.x = 1024; backBtn.y = 2000; backBtn.interactive = true; backBtn.buttonMode = true; backBtn.down = function () { seeAllBtn.down(); }; game.addChild(backBtn); } else if (idx === 6) { // Monster Knockout Room: show the text only (no special gameplay) var koText = new Text2('Trick the monster at the edge to bonk its head and see stars!', { size: 80, fill: 0xffff00 }); koText.anchor.set(0.5, 0.5); koText.x = 1024; koText.y = 1366; game.addChild(koText); } else if (idx === 7) { // Distorted UI Room: play normal game but with UI distortion // (reuse main game logic, but set isDistortedUI = true) // You can copy the main game setup here, but set isDistortedUI = true // For brevity, just show a message var distText = new Text2('Distorted UI Room\n(Play the main game with distorted UI!)', { size: 80, fill: 0xff8888 }); distText.anchor.set(0.5, 0.5); distText.x = 1024; distText.y = 1366; game.addChild(distText); } else if (idx === 8) { // Big Monster Room: spawn a huge monster and player if (typeof player === "undefined" || !player) { player = new Player(); } player.x = 1024; player.y = 1366; game.addChild(player); var bigMonster = new Monster(); bigMonster.x = 200; bigMonster.y = 200; bigMonster.scaleX = 8; bigMonster.scaleY = 8; bigMonster.speed = 2; game.addChild(bigMonster); // Add arrow buttons for movement var upButton = game.addChild(new ArrowButton('up')); upButton.x = 1024; upButton.y = 2500; var downButton = game.addChild(new ArrowButton('down')); downButton.x = 1024; downButton.y = 2620; var leftButton = game.addChild(new ArrowButton('left')); leftButton.x = 904; leftButton.y = 2560; var rightButton = game.addChild(new ArrowButton('right')); rightButton.x = 1144; rightButton.y = 2560; var playerSpeed = 5; game.update = function () { if (upButton.isPressed) player.y = Math.max(50, player.y - playerSpeed); if (downButton.isPressed) player.y = Math.min(2682, player.y + playerSpeed); if (leftButton.isPressed) player.x = Math.max(50, player.x - playerSpeed); if (rightButton.isPressed) player.x = Math.min(1998, player.x + playerSpeed); if (bigMonster && bigMonster.update) bigMonster.update(); // Add back button var backBtn = new Text2('Back to Easter Egg Menu', { size: 50, fill: 0xffff00 }); backBtn.anchor.set(0.5, 0.5); backBtn.x = 1024; backBtn.y = 2000; backBtn.interactive = true; backBtn.buttonMode = true; backBtn.down = function () { seeAllBtn.down(); }; game.addChild(backBtn); }; } else if (idx === 9) { // Normal Game Room: restart the main game // For simplicity, reload the page or show a message var normalText = new Text2('Normal Game Room\n(Play the main game!)', { size: 80, fill: 0xcccccc }); normalText.anchor.set(0.5, 0.5); normalText.x = 1024; normalText.y = 1366; game.addChild(normalText); } }; game.addChild(playBtn); } // Add a back button to return to the menu var backBtn = new Text2('Back to Easter Egg Menu', { size: 50, fill: 0xffff00 }); backBtn.anchor.set(0.5, 0.5); backBtn.x = 1024; backBtn.y = 1800; backBtn.interactive = true; backBtn.buttonMode = true; backBtn.down = function () { // Re-show the menu seeAllBtn.down(); }; game.addChild(backBtn); }; game.addChild(btn); })(i); } // Add a note for the developer var devNote = new Text2('This menu is only visible to the developer (upit user).\nAll secret/rare rooms are previewed here for testing.', { size: 40, fill: 0x00ff00 }); devNote.anchor.set(0.5, 0); devNote.x = 1024; devNote.y = 1750; game.addChild(devNote); }; promptBg.addChild(seeAllBtn); promptBg._easterEggBtn = seeAllBtn; } } } function setupEasterEggBtnTimeout() { if (easterEggBtnTimeout) LK.clearTimeout(easterEggBtnTimeout); easterEggBtnTimeout = LK.setTimeout(function () { showEasterEggBtnIfPasswordEntered(); }, 5000); } // Call this whenever passwordValue changes if (typeof updateInputDisplay === "function") { var oldUpdateInputDisplay = updateInputDisplay; updateInputDisplay = function updateInputDisplay() { oldUpdateInputDisplay(); setupEasterEggBtnTimeout(); }; } setupEasterEggBtnTimeout(); // Error text var errorText = new Text2('', { size: 40, fill: 0xff0000 }); errorText.anchor.set(0.5, 0); errorText.x = 0; errorText.y = 100; promptBg.addChild(errorText); // Confirm button var confirmBtn = new Text2('Confirm', { size: 60, fill: 0x00ff00 }); confirmBtn.anchor.set(0.5, 0); confirmBtn.x = 0; confirmBtn.y = 200; confirmBtn.interactive = false; confirmBtn.buttonMode = false; promptBg.addChild(confirmBtn); // Keyboard UI removed // When confirm is pressed, set the .text fields for validation confirmBtn.down = function () { if (!confirmBtn.interactive) return; if (typeof passwordInput !== "undefined" && passwordInput && typeof passwordValue === "string" && passwordValue.length > 0) { passwordInput.setText(passwordValue); } else if (typeof passwordInput !== "undefined" && passwordInput) { passwordInput.setText(""); } var enteredPass = (typeof passwordValue === "string" ? passwordValue : "").trim(); if (enteredPass === "199268") { // Remove all game elements from the screen (if any) for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } // Set background to dark game.setBackgroundColor(0x000000); // Show only the username/password UI with virtual keyboard in the dark room var promptBg = new Container(); promptBg._isDevPrompt = true; // Large dark rectangle for the login UI var bgAsset = promptBg.attachAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, scaleX: 8, scaleY: 6, color: 0x111122 }); promptBg.x = 1024; promptBg.y = 1366; game.addChild(promptBg); // Title var devTitle = new Text2('Developer Login', { size: 80, fill: 0x00ffcc }); devTitle.anchor.set(0.5, 0); devTitle.x = 0; devTitle.y = -400; promptBg.addChild(devTitle); // (Username input removed) // Password label var passwordPrompt = new Text2('Password:', { size: 60, fill: 0xffffff }); passwordPrompt.anchor.set(0.5, 0); passwordPrompt.x = 0; passwordPrompt.y = -60; promptBg.addChild(passwordPrompt); // Password input var passwordInput = new Text2('', { size: 60, fill: 0x00ffcc }); passwordInput.anchor.set(0.5, 0); passwordInput.x = 0; passwordInput.y = 10; promptBg.addChild(passwordInput); // Error text var errorText = new Text2('', { size: 40, fill: 0xff0000 }); errorText.anchor.set(0.5, 0); errorText.x = 0; errorText.y = 100; promptBg.addChild(errorText); // Confirm button var confirmBtn = new Text2('Confirm', { size: 60, fill: 0x00ff00 }); confirmBtn.anchor.set(0.5, 0); confirmBtn.x = 0; confirmBtn.y = 200; confirmBtn.interactive = false; confirmBtn.buttonMode = false; promptBg.addChild(confirmBtn); // Add logic to enable/disable confirm button based on password input var updateConfirmBtnState = function updateConfirmBtnState() { var enteredPass = (typeof passwordValue === "string" ? passwordValue : "").trim(); if (enteredPass === "199268") { confirmBtn.interactive = true; confirmBtn.buttonMode = true; confirmBtn.alpha = 1.0; errorText.setText(''); } else { confirmBtn.interactive = false; confirmBtn.buttonMode = false; confirmBtn.alpha = 0.5; } }; // Built-in virtual keyboard for username/password input var inputMode = "password"; var passwordValue = ""; var keyboardRows = ["0123", "4567", "89"]; var keyboardButtons = []; var updateInputDisplay = function updateInputDisplay() { passwordInput.setText(passwordValue); updateConfirmBtnState(); var enteredPass = (typeof passwordValue === "string" ? passwordValue : "").trim(); if (enteredPass === "199268") { isTestChancesRoom = true; // Remove all game elements from the screen (if any) for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } // Set background to dark game.setBackgroundColor(0x000000); // Title var devTitle = new Text2('TEST CHANCES ROOM', { size: 100, fill: 0x00ff00 }); devTitle.anchor.set(0.5, 0); devTitle.x = 1024; devTitle.y = 80; game.addChild(devTitle); // 1. Secret Black Room var secretText = new Text2('Secret Black Room:\nYou found the room with the lowest percent chance of the player spotting into\nLucky you!', { size: 60, fill: 0x00ff00 }); secretText.anchor.set(0.5, 0); secretText.x = 1024; secretText.y = 250; game.addChild(secretText); // 2. Black Box Win Room var winText = new Text2('Black Box Win Room:\nYou won!\nYou found the blue box!\n(It has a 10% chance of spawning)', { size: 60, fill: 0x00ffff }); winText.anchor.set(0.5, 0); winText.x = 1024; winText.y = 500; game.addChild(winText); // 3. Monster Win Room var monsterWinText = new Text2('Monster Win Room:\nThe monster won?', { size: 60, fill: 0xffffff }); monsterWinText.anchor.set(0.5, 0); monsterWinText.x = 1024; monsterWinText.y = 700; game.addChild(monsterWinText); // 4. Tiny Edge Button Room var foundButtonText = new Text2('Tiny Edge Button Room:\nYou found this very small button.\nThis is not the win.\nSurvive the monsters for 10 seconds!', { size: 50, fill: 0xffffff }); foundButtonText.anchor.set(0.5, 0); foundButtonText.x = 1024; foundButtonText.y = 900; game.addChild(foundButtonText); // 5. Tiny Monster Horde var tinyHordeText = new Text2('Tiny Monster Horde:\n0.000000000001% chance for 100 tiny monsters!', { size: 50, fill: 0xffcc00 }); tinyHordeText.anchor.set(0.5, 0); tinyHordeText.x = 1024; tinyHordeText.y = 1100; game.addChild(tinyHordeText); // 6. Glitch Room var glitchText = new Text2('Glitch Room:\nERROR: monster is not found\n[404]', { size: 60, fill: 0xff00ff }); glitchText.anchor.set(0.5, 0); glitchText.x = 1024; glitchText.y = 1300; game.addChild(glitchText); // 7. Monster Knockout Room var koText = new Text2('Monster Knockout:\nTrick the monster at the edge to bonk its head and see stars!', { size: 50, fill: 0xffff00 }); koText.anchor.set(0.5, 0); koText.x = 1024; koText.y = 1500; game.addChild(koText); // 8. Distorted UI Room var distText = new Text2('Distorted UI:\n0.4% chance for all UI/text to be distorted', { size: 50, fill: 0xff8888 }); distText.anchor.set(0.5, 0); distText.x = 1024; distText.y = 1700; game.addChild(distText); // 9. Big Monster Room var bigMonText = new Text2('Big Monster:\n3% chance for a huge monster at game start', { size: 50, fill: 0xff0000 }); bigMonText.anchor.set(0.5, 0); bigMonText.x = 1024; bigMonText.y = 1900; game.addChild(bigMonText); // 10. Normal Game Room var normalText = new Text2('Normal Game:\nAll normal gameplay elements', { size: 50, fill: 0xcccccc }); normalText.anchor.set(0.5, 0); normalText.x = 1024; normalText.y = 2100; game.addChild(normalText); // Add a note for the developer var devNote = new Text2('This room is only visible to the developer (upit user).\nAll secret/rare rooms are previewed here for testing.', { size: 40, fill: 0x00ff00 }); devNote.anchor.set(0.5, 0); devNote.x = 1024; devNote.y = 2300; game.addChild(devNote); // Add a button to view all secrets/Easter egg chances var viewSecretsBtn = new Text2('View All Secrets/Easter Egg Chances', { size: 70, fill: 0xffff00 }); viewSecretsBtn.anchor.set(0.5, 0.5); viewSecretsBtn.x = 1024; viewSecretsBtn.y = 2500; viewSecretsBtn.interactive = true; viewSecretsBtn.buttonMode = true; viewSecretsBtn.down = function () { // Show a popup or highlight all the secrets (for now, just flash the screen) LK.effects.flashScreen(0x00ff00, 800); // Optionally, you could show a more detailed overlay here }; game.addChild(viewSecretsBtn); } else if (typeof passwordValue === "string" && passwordValue.length === 6 && enteredPass !== "199268") { // Start a 5 second timer to transport to tiny monster horde room if (typeof wrongPasswordTimeout !== "undefined" && wrongPasswordTimeout) { LK.clearTimeout(wrongPasswordTimeout); } wrongPasswordTimeout = LK.setTimeout(function () { // Remove all game elements from the screen (if any) for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } game.setBackgroundColor(0x000000); // Center player in a long room far away for the tiny monster horde if (typeof player === "undefined" || !player) { player = new Player(); } // Place player in a long room far away (e.g. y = 4000, x = 1024) player.x = 1024; player.y = 4000; game.addChild(player); // Spawn 100 tiny monsters at random positions in the same long room if (typeof tinyMonsters === "undefined") tinyMonsters = []; tinyMonsters.length = 0; for (var i = 0; i < 100; i++) { var tmon = new Monster(); tmon.x = 100 + Math.random() * 1848; // Place monsters in the same long room (y = 3500 to 4500) tmon.y = 3500 + Math.random() * 1000; tmon.scaleX = 0.18; tmon.scaleY = 0.18; tmon.speed = 3.5 + Math.random() * 1.5; tinyMonsters.push(tmon); game.addChild(tmon); } // Add arrow buttons for movement var upButton = game.addChild(new ArrowButton('up')); upButton.x = 1024; upButton.y = 2500; var downButton = game.addChild(new ArrowButton('down')); downButton.x = 1024; downButton.y = 2620; var leftButton = game.addChild(new ArrowButton('left')); leftButton.x = 904; leftButton.y = 2560; var rightButton = game.addChild(new ArrowButton('right')); rightButton.x = 1144; rightButton.y = 2560; var playerSpeed = 5; // Override game.update for this room game.update = function () { for (var i = 0; i < tinyMonsters.length; i++) { var tmon = tinyMonsters[i]; if (tmon.update) tmon.update(); var caught = tmon.intersects(player); if (!tmon.lastPlayerIntersecting && caught) { var deathSound = LK.getSound('deathSound'); deathSound.volume = 1; deathSound.play(); LK.effects.flashScreen(0xff0000, 1000); LK.setTimeout(function () { player.x = 1024; player.y = 1366; for (var j = 0; j < tinyMonsters.length; j++) { tinyMonsters[j].x = 100 + Math.random() * 1848; tinyMonsters[j].y = 100 + Math.random() * 2532; } }, 1500); } tmon.lastPlayerIntersecting = caught; } // Player movement if (upButton.isPressed) player.y = Math.max(50, player.y - playerSpeed); if (downButton.isPressed) player.y = Math.min(2682, player.y + playerSpeed); if (leftButton.isPressed) player.x = Math.max(50, player.x - playerSpeed); if (rightButton.isPressed) player.x = Math.min(1998, player.x + playerSpeed); }; }, 5000); } }; // Add logic to enable/disable confirm button based on password input var updateConfirmBtnState = function updateConfirmBtnState() { var enteredPass = (typeof passwordValue === "string" ? passwordValue : "").trim(); if (enteredPass === "199268") { confirmBtn.interactive = true; confirmBtn.buttonMode = true; confirmBtn.alpha = 1.0; errorText.setText(''); } else { confirmBtn.interactive = false; confirmBtn.buttonMode = false; confirmBtn.alpha = 0.5; } }; passwordInput.interactive = true; passwordInput.buttonMode = true; passwordInput.down = function () { inputMode = "password"; errorText.setText(''); passwordInput.fill = 0xffff00; }; // Draw keyboard var kbStartY = 350; var keyBtnSize = 120; var keyBtnSpacing = 160; for (var row = 0; row < keyboardRows.length; row++) { var chars = keyboardRows[row]; for (var col = 0; col < chars.length; col++) { (function (row, col, c) { var btn = new Text2(c, { size: keyBtnSize, fill: 0xcccccc }); btn.anchor.set(0.5, 0.5); btn.x = (col - (chars.length - 1) / 2) * keyBtnSpacing; btn.y = kbStartY + row * keyBtnSpacing; btn.interactive = true; btn.buttonMode = true; // Set hitArea to match the button visual size btn.hitArea = { x: -keyBtnSize / 2, y: -keyBtnSize / 2, width: keyBtnSize, height: keyBtnSize }; btn.down = function () { if (passwordValue.length < 6) { passwordValue += c; updateInputDisplay(); updateConfirmBtnState(); } }; promptBg.addChild(btn); keyboardButtons.push(btn); })(row, col, chars[col]); } } // Add backspace button var backspaceBtn = new Text2('⌫', { size: keyBtnSize, fill: 0xff8888 }); backspaceBtn.anchor.set(0.5, 0.5); backspaceBtn.x = -keyBtnSpacing * 1.2; backspaceBtn.y = kbStartY + 4 * keyBtnSpacing; backspaceBtn.interactive = true; backspaceBtn.buttonMode = true; backspaceBtn.down = function () { if (passwordValue.length > 0) { passwordValue = passwordValue.slice(0, -1); } updateInputDisplay(); updateConfirmBtnState(); updateConfirmBtnState(); }; promptBg.addChild(backspaceBtn); // (space button removed so there is no space character input) // Add clear button var clearBtn = new Text2('clear', { size: keyBtnSize, fill: 0xcccccc }); clearBtn.anchor.set(0.5, 0.5); clearBtn.x = keyBtnSpacing * 1.2; clearBtn.y = kbStartY + 4 * keyBtnSpacing; clearBtn.interactive = true; clearBtn.buttonMode = true; clearBtn.down = function () { passwordValue = ""; updateInputDisplay(); updateConfirmBtnState(); updateConfirmBtnState(); }; promptBg.addChild(clearBtn); // When confirm is pressed, set the .text fields for validation confirmBtn.down = function () { if (!confirmBtn.interactive) return; if (typeof passwordInput !== "undefined" && passwordInput && typeof passwordValue === "string" && passwordValue.length > 0) { passwordInput.setText(Array(passwordValue.length + 1).join("*")); } else if (typeof passwordInput !== "undefined" && passwordInput) { passwordInput.setText(""); } var enteredPass = (typeof passwordValue === "string" ? passwordValue : "").trim(); if (enteredPass === "199268") { isTestChancesRoom = true; // Remove all game elements from the screen (if any) for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } // Set background to dark game.setBackgroundColor(0x000000); // Title var devTitle = new Text2('TEST CHANCES ROOM', { size: 100, fill: 0x00ff00 }); devTitle.anchor.set(0.5, 0); devTitle.x = 1024; devTitle.y = 80; game.addChild(devTitle); // 1. Secret Black Room var secretText = new Text2('Secret Black Room:\nYou found the room with the lowest percent chance of the player spotting into\nLucky you!', { size: 60, fill: 0x00ff00 }); secretText.anchor.set(0.5, 0); secretText.x = 1024; secretText.y = 250; game.addChild(secretText); // 2. Black Box Win Room var winText = new Text2('Black Box Win Room:\nYou won!\nYou found the blue box!\n(It has a 10% chance of spawning)', { size: 60, fill: 0x00ffff }); winText.anchor.set(0.5, 0); winText.x = 1024; winText.y = 500; game.addChild(winText); // 3. Monster Win Room var monsterWinText = new Text2('Monster Win Room:\nThe monster won?', { size: 60, fill: 0xffffff }); monsterWinText.anchor.set(0.5, 0); monsterWinText.x = 1024; monsterWinText.y = 700; game.addChild(monsterWinText); // 4. Tiny Edge Button Room var foundButtonText = new Text2('Tiny Edge Button Room:\nYou found this very small button.\nThis is not the win.\nSurvive the monsters for 10 seconds!', { size: 50, fill: 0xffffff }); foundButtonText.anchor.set(0.5, 0); foundButtonText.x = 1024; foundButtonText.y = 900; game.addChild(foundButtonText); // 5. Tiny Monster Horde var tinyHordeText = new Text2('Tiny Monster Horde:\n0.000000000001% chance for 100 tiny monsters!', { size: 50, fill: 0xffcc00 }); tinyHordeText.anchor.set(0.5, 0); tinyHordeText.x = 1024; tinyHordeText.y = 1100; game.addChild(tinyHordeText); // 6. Glitch Room var glitchText = new Text2('Glitch Room:\nERROR: monster is not found\n[404]', { size: 60, fill: 0xff00ff }); glitchText.anchor.set(0.5, 0); glitchText.x = 1024; glitchText.y = 1300; game.addChild(glitchText); // 7. Monster Knockout Room var koText = new Text2('Monster Knockout:\nTrick the monster at the edge to bonk its head and see stars!', { size: 50, fill: 0xffff00 }); koText.anchor.set(0.5, 0); koText.x = 1024; koText.y = 1500; game.addChild(koText); // 8. Distorted UI Room var distText = new Text2('Distorted UI:\n0.4% chance for all UI/text to be distorted', { size: 50, fill: 0xff8888 }); distText.anchor.set(0.5, 0); distText.x = 1024; distText.y = 1700; game.addChild(distText); // 9. Big Monster Room var bigMonText = new Text2('Big Monster:\n3% chance for a huge monster at game start', { size: 50, fill: 0xff0000 }); bigMonText.anchor.set(0.5, 0); bigMonText.x = 1024; bigMonText.y = 1900; game.addChild(bigMonText); // 10. Normal Game Room var normalText = new Text2('Normal Game:\nAll normal gameplay elements', { size: 50, fill: 0xcccccc }); normalText.anchor.set(0.5, 0); normalText.x = 1024; normalText.y = 2100; game.addChild(normalText); // Add a note for the developer var devNote = new Text2('This room is only visible to the developer (upit user).\nAll secret/rare rooms are previewed here for testing.', { size: 40, fill: 0x00ff00 }); devNote.anchor.set(0.5, 0); devNote.x = 1024; devNote.y = 2300; game.addChild(devNote); // Add a button to view all secrets/Easter egg chances var viewSecretsBtn = new Text2('View All Secrets/Easter Egg Chances', { size: 70, fill: 0xffff00 }); viewSecretsBtn.anchor.set(0.5, 0.5); viewSecretsBtn.x = 1024; viewSecretsBtn.y = 2500; viewSecretsBtn.interactive = true; viewSecretsBtn.buttonMode = true; viewSecretsBtn.down = function () { LK.effects.flashScreen(0x00ff00, 800); }; game.addChild(viewSecretsBtn); } else { if (typeof errorText !== "undefined" && errorText && typeof errorText.setText === "function") { errorText.setText('Incorrect username or password!'); } } }; if (typeof updateInputDisplay === "function") { updateInputDisplay(); } if (typeof selectInput === "function") { selectInput("username"); } } else { if (typeof errorText !== "undefined" && errorText && typeof errorText.setText === "function") { errorText.setText('Incorrect username or password!'); } // Spawn 100 tiny monsters in a black room for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } game.setBackgroundColor(0x000000); // Center player in a long room far away for the tiny monster horde if (typeof player === "undefined" || !player) { player = new Player(); } // Place player in a long room far away (e.g. y = 4000, x = 1024) player.x = 1024; player.y = 4000; game.addChild(player); // Spawn 100 tiny monsters at random positions in the same long room if (typeof tinyMonsters === "undefined") tinyMonsters = []; tinyMonsters.length = 0; for (var i = 0; i < 100; i++) { var tmon = new Monster(); tmon.x = 100 + Math.random() * 1848; // Place monsters in the same long room (y = 3500 to 4500) tmon.y = 3500 + Math.random() * 1000; tmon.scaleX = 0.18; tmon.scaleY = 0.18; tmon.speed = 3.5 + Math.random() * 1.5; tinyMonsters.push(tmon); game.addChild(tmon); } // Add arrow buttons for movement var upButton = game.addChild(new ArrowButton('up')); upButton.x = 1024; upButton.y = 2500; var downButton = game.addChild(new ArrowButton('down')); downButton.x = 1024; downButton.y = 2620; var leftButton = game.addChild(new ArrowButton('left')); leftButton.x = 904; leftButton.y = 2560; var rightButton = game.addChild(new ArrowButton('right')); rightButton.x = 1144; rightButton.y = 2560; var playerSpeed = 5; // Override game.update for this room game.update = function () { for (var i = 0; i < tinyMonsters.length; i++) { var tmon = tinyMonsters[i]; if (tmon.update) tmon.update(); var caught = tmon.intersects(player); if (!tmon.lastPlayerIntersecting && caught) { var deathSound = LK.getSound('deathSound'); deathSound.volume = 1; deathSound.play(); LK.effects.flashScreen(0xff0000, 1000); LK.setTimeout(function () { player.x = 1024; player.y = 1366; for (var j = 0; j < tinyMonsters.length; j++) { tinyMonsters[j].x = 100 + Math.random() * 1848; tinyMonsters[j].y = 100 + Math.random() * 2532; } }, 1500); } tmon.lastPlayerIntersecting = caught; } // Player movement if (upButton.isPressed) player.y = Math.max(50, player.y - playerSpeed); if (downButton.isPressed) player.y = Math.min(2682, player.y + playerSpeed); if (leftButton.isPressed) player.x = Math.max(50, player.x - playerSpeed); if (rightButton.isPressed) player.x = Math.min(1998, player.x + playerSpeed); }; } }; if (typeof updateInputDisplay === "function") { updateInputDisplay(); } if (typeof selectInput === "function") { selectInput("username"); } // Built-in virtual keyboard for username/password input var inputMode = "password"; var passwordValue = ""; var keyboardRows = ["0123", "4567", "89"]; var keyboardButtons = []; var updateInputDisplay = function updateInputDisplay() { if (typeof passwordValue === "string" && passwordValue.length > 0) { passwordInput.setText(passwordValue); } else { passwordInput.setText(""); } // If 6 chars entered, check if correct, and if so, start 5s timer for Easter Egg/Secrets button if (typeof passwordValue === "string" && passwordValue.length === 6) { var enteredPass = passwordValue.trim(); if (enteredPass === "199268") { if (typeof easterEggBtnTimeout !== "undefined") { if (easterEggBtnTimeout) LK.clearTimeout(easterEggBtnTimeout); } easterEggBtnTimeout = LK.setTimeout(function () { if (typeof showEasterEggBtnIfPasswordEntered === "function") showEasterEggBtnIfPasswordEntered(); }, 5000); } } }; passwordInput.interactive = true; passwordInput.buttonMode = true; passwordInput.down = function () { inputMode = "password"; errorText.setText(''); passwordInput.fill = 0xffff00; }; // Draw keyboard var kbStartY = 550; var keyBtnSize = 120; var keyBtnSpacing = 160; for (var row = 0; row < keyboardRows.length; row++) { var chars = keyboardRows[row]; for (var col = 0; col < chars.length; col++) { (function (row, col, c) { var btn = new Text2(c, { size: keyBtnSize, fill: 0xcccccc }); btn.anchor.set(0.5, 0.5); btn.x = (col - (chars.length - 1) / 2) * keyBtnSpacing; btn.y = kbStartY + row * keyBtnSpacing; btn.interactive = true; btn.buttonMode = true; // Set hitArea to match the button visual size btn.hitArea = { x: -keyBtnSize / 2, y: -keyBtnSize / 2, width: keyBtnSize, height: keyBtnSize }; btn.down = function () { if (passwordValue.length < 6) { passwordValue += c; updateInputDisplay(); } }; promptBg.addChild(btn); keyboardButtons.push(btn); })(row, col, chars[col]); } } // Add backspace button var backspaceBtn = new Text2('⌫', { size: keyBtnSize, fill: 0xff8888 }); backspaceBtn.anchor.set(0.5, 0.5); backspaceBtn.x = -keyBtnSpacing * 1.2; backspaceBtn.y = kbStartY + 4 * keyBtnSpacing; backspaceBtn.interactive = true; backspaceBtn.buttonMode = true; backspaceBtn.down = function () { if (passwordValue.length > 0) { passwordValue = passwordValue.slice(0, -1); } updateInputDisplay(); }; promptBg.addChild(backspaceBtn); // (space button removed so there is no space character input) // Add clear button var clearBtn = new Text2('clear', { size: keyBtnSize, fill: 0xcccccc }); clearBtn.anchor.set(0.5, 0.5); clearBtn.x = keyBtnSpacing * 1.2; clearBtn.y = kbStartY + 4 * keyBtnSpacing; clearBtn.interactive = true; clearBtn.buttonMode = true; clearBtn.down = function () { passwordValue = ""; updateInputDisplay(); }; promptBg.addChild(clearBtn); // When confirm is pressed, set the .text fields for validation confirmBtn.down = function () { if (typeof passwordInput !== "undefined" && passwordInput && typeof passwordValue === "string" && passwordValue.length > 0) { passwordInput.setText(passwordValue); } else if (typeof passwordInput !== "undefined" && passwordInput) { passwordInput.setText(""); } var enteredPass = (typeof passwordValue === "string" ? passwordValue : "").trim(); if (enteredPass === "199268") { // Remove all game elements from the screen (if any) for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } // Set background to dark game.setBackgroundColor(0x000000); // Show only the username/password UI with virtual keyboard in the dark room var promptBg = new Container(); promptBg._isDevPrompt = true; // Large dark rectangle for the login UI var bgAsset = promptBg.attachAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, scaleX: 8, scaleY: 6, color: 0x111122 }); promptBg.x = 1024; promptBg.y = 1366; game.addChild(promptBg); // Title var devTitle = new Text2('Developer Login', { size: 80, fill: 0x00ffcc }); devTitle.anchor.set(0.5, 0); devTitle.x = 0; devTitle.y = -400; promptBg.addChild(devTitle); // (Username input removed) // Password label var passwordPrompt = new Text2('Password:', { size: 60, fill: 0xffffff }); passwordPrompt.anchor.set(0.5, 0); passwordPrompt.x = 0; passwordPrompt.y = -60; promptBg.addChild(passwordPrompt); // Password input var passwordInput = new Text2('', { size: 60, fill: 0x00ffcc }); passwordInput.anchor.set(0.5, 0); passwordInput.x = 0; passwordInput.y = 10; promptBg.addChild(passwordInput); // Error text var errorText = new Text2('', { size: 40, fill: 0xff0000 }); errorText.anchor.set(0.5, 0); errorText.x = 0; errorText.y = 100; promptBg.addChild(errorText); // Confirm button var confirmBtn = new Text2('Confirm', { size: 60, fill: 0x00ff00 }); confirmBtn.anchor.set(0.5, 0); confirmBtn.x = 0; confirmBtn.y = 200; confirmBtn.interactive = false; confirmBtn.buttonMode = false; confirmBtn.alpha = 0.5; promptBg.addChild(confirmBtn); // Built-in virtual keyboard for username/password input var inputMode = "password"; var passwordValue = ""; var keyboardRows = ["0123", "4567", "89"]; var keyboardButtons = []; var updateInputDisplay = function updateInputDisplay() { if (typeof passwordValue === "string" && passwordValue.length > 0) { passwordInput.setText(passwordValue); } else { passwordInput.setText(""); } updateConfirmBtnState(); }; // Add logic to enable/disable confirm button based on password input var updateConfirmBtnState = function updateConfirmBtnState() { var enteredPass = (typeof passwordValue === "string" ? passwordValue : "").trim(); if (enteredPass === "199268") { confirmBtn.interactive = true; confirmBtn.buttonMode = true; confirmBtn.alpha = 1.0; errorText.setText(''); } else { confirmBtn.interactive = false; confirmBtn.buttonMode = false; confirmBtn.alpha = 0.5; } }; passwordInput.interactive = true; passwordInput.buttonMode = true; passwordInput.down = function () { inputMode = "password"; errorText.setText(''); passwordInput.fill = 0xffff00; }; // Draw keyboard var kbStartY = 350; var keyBtnSize = 120; var keyBtnSpacing = 160; for (var row = 0; row < keyboardRows.length; row++) { var chars = keyboardRows[row]; for (var col = 0; col < chars.length; col++) { (function (row, col, c) { var btn = new Text2(c, { size: keyBtnSize, fill: 0xcccccc }); btn.anchor.set(0.5, 0.5); btn.x = (col - (chars.length - 1) / 2) * keyBtnSpacing; btn.y = kbStartY + row * keyBtnSpacing; btn.interactive = true; btn.buttonMode = true; // Set hitArea to match the button visual size btn.hitArea = { x: -keyBtnSize / 2, y: -keyBtnSize / 2, width: keyBtnSize, height: keyBtnSize }; btn.down = function () { if (passwordValue.length < 6) { passwordValue += c; updateInputDisplay(); } }; promptBg.addChild(btn); keyboardButtons.push(btn); })(row, col, chars[col]); } } // Add backspace button var backspaceBtn = new Text2('⌫', { size: keyBtnSize, fill: 0xff8888 }); backspaceBtn.anchor.set(0.5, 0.5); backspaceBtn.x = -keyBtnSpacing * 1.2; backspaceBtn.y = kbStartY + 4 * keyBtnSpacing; backspaceBtn.interactive = true; backspaceBtn.buttonMode = true; backspaceBtn.down = function () { if (passwordValue.length > 0) { passwordValue = passwordValue.slice(0, -1); } updateInputDisplay(); updateConfirmBtnState(); }; promptBg.addChild(backspaceBtn); // (space button removed so there is no space character input) // Add clear button var clearBtn = new Text2('clear', { size: keyBtnSize, fill: 0xcccccc }); clearBtn.anchor.set(0.5, 0.5); clearBtn.x = keyBtnSpacing * 1.2; clearBtn.y = kbStartY + 4 * keyBtnSpacing; clearBtn.interactive = true; clearBtn.buttonMode = true; clearBtn.down = function () { passwordValue = ""; updateInputDisplay(); updateConfirmBtnState(); }; promptBg.addChild(clearBtn); // When confirm is pressed, set the .text fields for validation confirmBtn.down = function () { if (!confirmBtn.interactive) return; if (typeof passwordInput !== "undefined" && passwordInput && typeof passwordValue === "string" && passwordValue.length > 0) { passwordInput.setText(passwordValue); } else if (typeof passwordInput !== "undefined" && passwordInput) { passwordInput.setText(""); } var enteredPass = (typeof passwordValue === "string" ? passwordValue : "").trim(); if (enteredPass === "199268") { // Already in developer room, do nothing or show a message if desired } else { if (typeof errorText !== "undefined" && errorText && typeof errorText.setText === "function") { errorText.setText('Incorrect username or password!'); } } }; updateInputDisplay(); selectInput("username"); } else { if (typeof errorText !== "undefined" && errorText && typeof errorText.setText === "function") { errorText.setText('Incorrect username or password!'); } } }; }; game.addChild(devButton); if (isTestChancesRoom) { // Remove all game elements from the screen (if any) for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } game.setBackgroundColor(0x000000); // Title var devTitle = new Text2('TEST CHANCES ROOM', { size: 100, fill: 0x00ff00 }); devTitle.anchor.set(0.5, 0); devTitle.x = 1024; devTitle.y = 80; game.addChild(devTitle); // 1. Secret Black Room var secretText = new Text2('Secret Black Room:\nYou found the room with the lowest percent chance of the player spotting into\nLucky you!', { size: 60, fill: 0x00ff00 }); secretText.anchor.set(0.5, 0); secretText.x = 1024; secretText.y = 250; game.addChild(secretText); // 2. Black Box Win Room var winText = new Text2('Black Box Win Room:\nYou won!\nYou found the blue box!\n(It has a 10% chance of spawning)', { size: 60, fill: 0x00ffff }); winText.anchor.set(0.5, 0); winText.x = 1024; winText.y = 500; game.addChild(winText); // 3. Monster Win Room var monsterWinText = new Text2('Monster Win Room:\nThe monster won?', { size: 60, fill: 0xffffff }); monsterWinText.anchor.set(0.5, 0); monsterWinText.x = 1024; monsterWinText.y = 700; game.addChild(monsterWinText); // 4. Tiny Edge Button Room var foundButtonText = new Text2('Tiny Edge Button Room:\nYou found this very small button.\nThis is not the win.\nSurvive the monsters for 10 seconds!', { size: 50, fill: 0xffffff }); foundButtonText.anchor.set(0.5, 0); foundButtonText.x = 1024; foundButtonText.y = 900; game.addChild(foundButtonText); // 5. Tiny Monster Horde var tinyHordeText = new Text2('Tiny Monster Horde:\n0.000000000001% chance for 100 tiny monsters!', { size: 50, fill: 0xffcc00 }); tinyHordeText.anchor.set(0.5, 0); tinyHordeText.x = 1024; tinyHordeText.y = 1100; game.addChild(tinyHordeText); // 6. Glitch Room var glitchText = new Text2('Glitch Room:\nERROR: monster is not found\n[404]', { size: 60, fill: 0xff00ff }); glitchText.anchor.set(0.5, 0); glitchText.x = 1024; glitchText.y = 1300; game.addChild(glitchText); // 7. Monster Knockout Room var koText = new Text2('Monster Knockout:\nTrick the monster at the edge to bonk its head and see stars!', { size: 50, fill: 0xffff00 }); koText.anchor.set(0.5, 0); koText.x = 1024; koText.y = 1500; game.addChild(koText); // 8. Distorted UI Room var distText = new Text2('Distorted UI:\n0.4% chance for all UI/text to be distorted', { size: 50, fill: 0xff8888 }); distText.anchor.set(0.5, 0); distText.x = 1024; distText.y = 1700; game.addChild(distText); // 9. Big Monster Room var bigMonText = new Text2('Big Monster:\n3% chance for a huge monster at game start', { size: 50, fill: 0xff0000 }); bigMonText.anchor.set(0.5, 0); bigMonText.x = 1024; bigMonText.y = 1900; game.addChild(bigMonText); // 10. Normal Game Room var normalText = new Text2('Normal Game:\nAll normal gameplay elements', { size: 50, fill: 0xcccccc }); normalText.anchor.set(0.5, 0); normalText.x = 1024; normalText.y = 2100; game.addChild(normalText); // Add a note for the developer var devNote = new Text2('This room is only visible to the developer (upit user).\nAll secret/rare rooms are previewed here for testing.', { size: 40, fill: 0x00ff00 }); devNote.anchor.set(0.5, 0); devNote.x = 1024; devNote.y = 2300; game.addChild(devNote); } else if (Math.random() < 0.0000001) { // Remove all game elements from the screen (if any) for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } // Fill background with black game.setBackgroundColor(0x000000); // Show green text in the center var secretText = new Text2('You found the room with the lowest percent chance of the player spotting into\nLucky you!', { size: 100, fill: 0x00ff00 }); secretText.anchor.set(0.5, 0.5); secretText.x = 1024; secretText.y = 1366; game.addChild(secretText); } else { // Create game title var titleText = new Text2('MONSTER ESCAPE', { size: 80, fill: 0xFF0000 }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 100; game.addChild(titleText); // Create instructions var instructionsText = new Text2('Survive as long as possible!\nMonster gets faster every minute', { size: 40, fill: 0x333333 }); instructionsText.anchor.set(0.5, 0); instructionsText.x = 1024; instructionsText.y = 200; game.addChild(instructionsText); // Create score display var scoreText = new Text2('Time Survived: 0ms', { size: 50, fill: 0x000000 }); scoreText.anchor.set(0.5, 0); scoreText.x = 1024; scoreText.y = 300; game.addChild(scoreText); // Add death count display var deathCountText = new Text2('Deaths: 0', { size: 40, fill: 0x880000 }); deathCountText.anchor.set(0.5, 0); deathCountText.x = 1024; deathCountText.y = 370; game.addChild(deathCountText); ; } var player = game.addChild(new Player()); player.x = 1024; // Center horizontally player.y = 1366; // Center vertically // Add trail effect to player var playerTrail = []; // --- Track player deaths for black room --- var playerDeathCount = 0; var blackRoomActive = false; // Add a small grey button at the right edge of the map, but still seeable var edgeButton = new Container(); var edgeButtonAsset = edgeButton.attachAsset('edgeButtonGrey', { anchorX: 0.5, anchorY: 0.5, width: 12, height: 12, color: 0x888888, shape: 'box' }); // Place the button at the right edge, vertically centered, but still visible edgeButton.x = 2048 - 60; // 60px from the right edge edgeButton.y = 1366; // center vertically game.addChild(edgeButton); var monster; var tinyMonsters = []; // 0.000000000001% chance for tiny monster horde if (Math.random() < 0.0000000000001) { // Main monster becomes extra small monster = game.addChild(new Monster()); monster.x = 200; monster.y = 200; monster.scaleX = 0.18; monster.scaleY = 0.18; monster.speed = 3.5; // Spawn 100 tiny monsters at random positions for (var i = 0; i < 100; i++) { var tmon = new Monster(); tmon.x = 100 + Math.random() * 1848; tmon.y = 100 + Math.random() * 2532; tmon.scaleX = 0.18; tmon.scaleY = 0.18; tmon.speed = 3.5 + Math.random() * 1.5; tinyMonsters.push(tmon); game.addChild(tmon); } } else { monster = game.addChild(new Monster()); monster.x = 200; monster.y = 200; // Small chance to make the monster really, really big at game start if (Math.random() < 0.03) { // 3% chance monster.scaleX = 8; monster.scaleY = 8; } } // 10% chance to spawn a black box var hasBlackBox = false; var blackBox = null; if (Math.random() < 0.1) { hasBlackBox = true; blackBox = new Container(); var boxAsset = blackBox.attachAsset('blackBox', { anchorX: 0.5, anchorY: 0.5, width: 180, height: 180, color: 0x000000, shape: 'box' }); // Place black box at a random location not too close to player or monster var safe = false; var bx = 0, by = 0; while (!safe) { bx = 200 + Math.random() * (2048 - 400); by = 400 + Math.random() * (2732 - 800); var distToPlayer = Math.sqrt((bx - player.x) * (bx - player.x) + (by - player.y) * (by - player.y)); var distToMonster = Math.sqrt((bx - monster.x) * (bx - monster.x) + (by - monster.y) * (by - monster.y)); if (distToPlayer > 400 && distToMonster > 400) safe = true; } blackBox.x = bx; blackBox.y = by; game.addChild(blackBox); } var foundBlackBox = false; // Even smaller chance to start with all UI/text distorted var isDistortedUI = false; if (Math.random() < 0.004) { // 0.4% chance isDistortedUI = true; } // Arrow control buttons var upButton = game.addChild(new ArrowButton('up')); upButton.x = 1024; upButton.y = 2500; var downButton = game.addChild(new ArrowButton('down')); downButton.x = 1024; downButton.y = 2620; var leftButton = game.addChild(new ArrowButton('left')); leftButton.x = 904; leftButton.y = 2560; var rightButton = game.addChild(new ArrowButton('right')); rightButton.x = 1144; rightButton.y = 2560; var playerSpeed = 5; var gameStartTime = Date.now(); game.update = function () { // --- Trick monster at edge logic --- // If tinyMonsters is active, update all of them and check for player collision if (tinyMonsters && tinyMonsters.length > 0) { for (var i = 0; i < tinyMonsters.length; i++) { var tmon = tinyMonsters[i]; if (tmon.update) tmon.update(); // Check collision with player var caught = tmon.intersects(player); if (!tmon.lastPlayerIntersecting && caught) { // Player caught! Play death sound and reset var deathSound = LK.getSound('deathSound'); deathSound.volume = 1; deathSound.play(); LK.effects.flashScreen(0xff0000, 1000); LK.setTimeout(function () { player.x = 1024; player.y = 1366; for (var j = 0; j < tinyMonsters.length; j++) { tinyMonsters[j].x = 100 + Math.random() * 1848; tinyMonsters[j].y = 100 + Math.random() * 2532; } gameStartTime = Date.now(); LK.setScore(0); }, 1500); } tmon.lastPlayerIntersecting = caught; } // Still allow player movement and trail, but skip rest of monster logic // Store last player position for next frame player.lastX = player.x; player.lastY = player.y; if (upButton.isPressed) { player.y = Math.max(50, player.y - playerSpeed); } if (downButton.isPressed) { player.y = Math.min(2682, player.y + playerSpeed); } if (leftButton.isPressed) { player.x = Math.max(50, player.x - playerSpeed); } if (rightButton.isPressed) { player.x = Math.min(1998, player.x + playerSpeed); } // Add player trail effect if (LK.ticks % 3 === 0) { playerTrail.push({ x: player.x, y: player.y, alpha: 0.7 }); } // Remove old trail points and update existing ones for (var i = playerTrail.length - 1; i >= 0; i--) { playerTrail[i].alpha -= 0.05; if (playerTrail[i].alpha <= 0) { playerTrail.splice(i, 1); } } // Remove star update references if knockout is over // knockout logic removed // Skip rest of update logic for normal monster return; } // --- Black Room Death Trigger --- if (!blackRoomActive && playerDeathCount >= 10) { blackRoomActive = true; if (typeof startBlackRoom === "function") startBlackRoom(); return; } // knockout logic removed // Store last player position for next frame player.lastX = player.x; player.lastY = player.y; // --- Glitch Room Movement Sequence Tracking --- // New logic: spam up 5 times in a row (within 2 seconds) to trigger glitch room if (typeof glitchMoveState === "undefined") { glitchMoveState = { upSpamCount: 0, lastUpTick: 0, lastPlayerY: player.y }; } // --- Hold Down 10s to Enter Glitch Room --- if (typeof glitchHoldState === "undefined") { glitchHoldState = { isHolding: false, holdStartTick: 0, triggered: false }; } // Listen for global down/up events to track holding if (typeof game._glitchHoldDownListener === "undefined") { game._glitchHoldDownListener = true; game.down = function (x, y, obj) { if (!glitchHoldState.isHolding) { glitchHoldState.isHolding = true; glitchHoldState.holdStartTick = LK.ticks; glitchHoldState.triggered = false; } if (typeof game._originalDown === "function") game._originalDown(x, y, obj); }; game.up = function (x, y, obj) { glitchHoldState.isHolding = false; glitchHoldState.holdStartTick = 0; glitchHoldState.triggered = false; if (typeof game._originalUp === "function") game._originalUp(x, y, obj); }; } // Check in update if held for 10 seconds (600 ticks) if (glitchHoldState.isHolding && !glitchHoldState.triggered && LK.ticks - glitchHoldState.holdStartTick >= 600) { glitchHoldState.triggered = true; // Remove all game elements for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } game.setBackgroundColor(0x000000); // Place player in center player.x = 1024; player.y = 1366; game.addChild(player); // Add glitchy monster var glitchMonster = new Monster(); glitchMonster.x = 200; glitchMonster.y = 200; glitchMonster.speed = 4.5; glitchMonster.update = function () { var dx = player.x - this.x + (Math.random() - 0.5) * 60; var dy = player.y - this.y + (Math.random() - 0.5) * 60; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 0) { this.x += dx / dist * this.speed; this.y += dy / dist * this.speed; } this.scaleX = 1.2 + Math.sin(LK.ticks * 0.2) * 0.7 + (Math.random() - 0.5) * 0.3; this.scaleY = 1.2 + Math.cos(LK.ticks * 0.2) * 0.7 + (Math.random() - 0.5) * 0.3; if (this.children[0]) { this.children[0].tint = Math.random() < 0.5 ? 0xff00ff : 0xffffff; } var caught = this.intersects(player); if (!this.lastPlayerIntersecting && caught) { LK.effects.flashScreen(0xff00ff, 1200); var loseText = new Text2('GLITCHY MONSTER CAUGHT YOU!\n[RESTARTING...]', { size: 100, fill: 0xff00ff }); loseText.anchor.set(0.5, 0.5); loseText.x = 1024; loseText.y = 1366; game.addChild(loseText); LK.setTimeout(function () { for (var k = game.children.length - 1; k >= 0; k--) { game.removeChild(game.children[k]); } game.setBackgroundColor(0x000000); player.x = 1024; player.y = 1366; game.addChild(player); game.addChild(glitchMonster); }, 1800); } this.lastPlayerIntersecting = caught; }; game.addChild(glitchMonster); // Add arrow buttons for movement var upButtonG = game.addChild(new ArrowButton('up')); upButtonG.x = 1024; upButtonG.y = 2500; var downButtonG = game.addChild(new ArrowButton('down')); downButtonG.x = 1024; downButtonG.y = 2620; var leftButtonG = game.addChild(new ArrowButton('left')); leftButtonG.x = 904; leftButtonG.y = 2560; var rightButtonG = game.addChild(new ArrowButton('right')); rightButtonG.x = 1144; rightButtonG.y = 2560; var playerSpeedG = 7; game.update = function () { if (upButtonG.isPressed) player.y = Math.max(50, player.y - playerSpeedG); if (downButtonG.isPressed) player.y = Math.min(2682, player.y + playerSpeedG); if (leftButtonG.isPressed) player.x = Math.max(50, player.x - playerSpeedG); if (rightButtonG.isPressed) player.x = Math.min(1998, player.x + playerSpeedG); if (glitchMonster && glitchMonster.update) glitchMonster.update(); // Always keep glitchText and backBtn in front of glitchMonster if (typeof glitchText !== "undefined" && glitchText && typeof game.setChildIndex === "function" && game.children.indexOf(glitchText) !== -1) { game.setChildIndex(glitchText, game.children.length - 1); } if (typeof backBtn !== "undefined" && backBtn && typeof game.setChildIndex === "function" && game.children.indexOf(backBtn) !== -1) { game.setChildIndex(backBtn, game.children.length - 1); } // Add glitchy screen shake var shake = (Math.random() - 0.5) * 30; player.x += (Math.random() - 0.5) * 4; player.y += (Math.random() - 0.5) * 4; game.x = shake; game.y = shake; }; // Show glitch room text var glitchText = new Text2('GLITCH ROOM\nRUN FROM THE GLITCHY MONSTER!', { size: 80, fill: 0xff00ff }); glitchText.anchor.set(0.5, 0.5); glitchText.x = 1024; glitchText.y = 300; game.addChild(glitchText); } // Detect up movement (player moves up by at least 10px in one tick) var movedUp = player.lastY - player.y > 9; if (movedUp) { // If last up was more than 2 seconds ago, reset count if (LK.ticks - glitchMoveState.lastUpTick > 120) { glitchMoveState.upSpamCount = 0; } glitchMoveState.upSpamCount++; glitchMoveState.lastUpTick = LK.ticks; } else if (LK.ticks - glitchMoveState.lastUpTick > 120) { // Timeout: if too long between ups, reset glitchMoveState.upSpamCount = 0; } // If spammed up 5 times, trigger glitch room if (glitchMoveState.upSpamCount >= 5) { // Remove all game elements for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } game.setBackgroundColor(0x000000); // Place player in center player.x = 1024; player.y = 1366; game.addChild(player); // Add glitchy monster var glitchMonster = new Monster(); glitchMonster.x = 200; glitchMonster.y = 200; glitchMonster.speed = 4.5; // Add visual glitch: random scale, color flash, and shake glitchMonster.update = function () { // Glitchy movement: chase player, but with random jitter var dx = player.x - this.x + (Math.random() - 0.5) * 60; var dy = player.y - this.y + (Math.random() - 0.5) * 60; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 0) { this.x += dx / dist * this.speed; this.y += dy / dist * this.speed; } // Glitchy scale and color this.scaleX = 1.2 + Math.sin(LK.ticks * 0.2) * 0.7 + (Math.random() - 0.5) * 0.3; this.scaleY = 1.2 + Math.cos(LK.ticks * 0.2) * 0.7 + (Math.random() - 0.5) * 0.3; if (this.children[0]) { this.children[0].tint = Math.random() < 0.5 ? 0xff00ff : 0xffffff; } // Check if caught player var caught = this.intersects(player); if (!this.lastPlayerIntersecting && caught) { LK.effects.flashScreen(0xff00ff, 1200); var loseText = new Text2('GLITCHY MONSTER CAUGHT YOU!\n[RESTARTING...]', { size: 100, fill: 0xff00ff }); loseText.anchor.set(0.5, 0.5); loseText.x = 1024; loseText.y = 1366; game.addChild(loseText); // Restart glitch room after short delay LK.setTimeout(function () { for (var k = game.children.length - 1; k >= 0; k--) { game.removeChild(game.children[k]); } game.setBackgroundColor(0x000000); player.x = 1024; player.y = 1366; game.addChild(player); game.addChild(glitchMonster); }, 1800); } this.lastPlayerIntersecting = caught; }; game.addChild(glitchMonster); // Add arrow buttons for movement var upButtonG = game.addChild(new ArrowButton('up')); upButtonG.x = 1024; upButtonG.y = 2500; var downButtonG = game.addChild(new ArrowButton('down')); downButtonG.x = 1024; downButtonG.y = 2620; var leftButtonG = game.addChild(new ArrowButton('left')); leftButtonG.x = 904; leftButtonG.y = 2560; var rightButtonG = game.addChild(new ArrowButton('right')); rightButtonG.x = 1144; rightButtonG.y = 2560; var playerSpeedG = 7; // Glitchy room update game.update = function () { if (upButtonG.isPressed) player.y = Math.max(50, player.y - playerSpeedG); if (downButtonG.isPressed) player.y = Math.min(2682, player.y + playerSpeedG); if (leftButtonG.isPressed) player.x = Math.max(50, player.x - playerSpeedG); if (rightButtonG.isPressed) player.x = Math.min(1998, player.x + playerSpeedG); if (glitchMonster && glitchMonster.update) glitchMonster.update(); // Always keep glitchText and backBtn in front of glitchMonster if (typeof glitchText !== "undefined" && glitchText && typeof game.setChildIndex === "function" && game.children.indexOf(glitchText) !== -1) { game.setChildIndex(glitchText, game.children.length - 1); } if (typeof backBtn !== "undefined" && backBtn && typeof game.setChildIndex === "function" && game.children.indexOf(backBtn) !== -1) { game.setChildIndex(backBtn, game.children.length - 1); } // Add glitchy screen shake var shake = (Math.random() - 0.5) * 30; player.x += (Math.random() - 0.5) * 4; player.y += (Math.random() - 0.5) * 4; game.x = shake; game.y = shake; }; // Show glitch room text var glitchText = new Text2('GLITCH ROOM\nRUN FROM THE GLITCHY MONSTER!', { size: 80, fill: 0xff00ff }); glitchText.anchor.set(0.5, 0.5); glitchText.x = 1024; glitchText.y = 300; game.addChild(glitchText); // Reset glitchMoveState so it can't be triggered again until restart glitchMoveState.upSpamCount = -999; } // Handle player movement with arrow buttons if (upButton.isPressed) { player.y = Math.max(50, player.y - playerSpeed); } if (downButton.isPressed) { player.y = Math.min(2682, player.y + playerSpeed); } if (leftButton.isPressed) { player.x = Math.max(50, player.x - playerSpeed); } if (rightButton.isPressed) { player.x = Math.min(1998, player.x + playerSpeed); } // Check for black box win condition if (hasBlackBox && blackBox && !foundBlackBox) { if (player.lastFoundBlackBox === undefined) player.lastFoundBlackBox = false; var isIntersectingBlackBox = player.intersects(blackBox); if (!player.lastFoundBlackBox && isIntersectingBlackBox) { foundBlackBox = true; // Remove all game elements from the screen for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } // Fill background with black game.setBackgroundColor(0x000000); // Show green text in the center var winText = new Text2('You won!\nYou found the blue box!\n(It has a 10% chance of spawning)', { size: 120, fill: 0x00ff00 }); winText.anchor.set(0.5, 0.5); winText.x = 1024; winText.y = 1366; game.addChild(winText); } player.lastFoundBlackBox = isIntersectingBlackBox; // --- Monster collides with black box: "The monster won?" --- if (monster.lastBlackBoxIntersecting === undefined) monster.lastBlackBoxIntersecting = false; var monsterIntersectingBlackBox = monster.intersects(blackBox); if (!monster.lastBlackBoxIntersecting && monsterIntersectingBlackBox) { // Remove all game elements from the screen for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } // Fill background with black game.setBackgroundColor(0x000000); // Show centered text var monsterWinText = new Text2('The monster won?', { size: 120, fill: 0xffffff }); monsterWinText.anchor.set(0.5, 0.5); monsterWinText.x = 1024; monsterWinText.y = 1366; game.addChild(monsterWinText); } monster.lastBlackBoxIntersecting = monsterIntersectingBlackBox; } // --- Secret tiny edge button room logic --- if (player.lastFoundEdgeButton === undefined) player.lastFoundEdgeButton = false; var isIntersectingEdgeButton = player.intersects(edgeButton); if (!player.lastFoundEdgeButton && isIntersectingEdgeButton) { // Remove all game elements from the screen for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } // Fill background with black game.setBackgroundColor(0x000000); // Show special text var foundButtonText = new Text2('You found this very small button.\nThis is not the win.\nSurvive the monsters for 10 seconds!', { size: 80, fill: 0xffffff }); foundButtonText.anchor.set(0.5, 0.5); foundButtonText.x = 1024; foundButtonText.y = 500; game.addChild(foundButtonText); // Add player to the center player.x = 1024; player.y = 2000; game.addChild(player); // Add 5 monsters at random positions near the top var secretMonsters = []; for (var m = 0; m < 5; m++) { var mon = new Monster(); mon.x = 400 + Math.random() * 1200; mon.y = 400 + Math.random() * 400; // Make monsters in secret room fast enough to catch a still player (speed 2.7 to 3.2) mon.speed = 2.7 + Math.random() * 0.5; secretMonsters.push(mon); game.addChild(mon); } // Add countdown text var countdownValue = 10; var countdownText = new Text2('10', { size: 200, fill: 0xff0000 }); countdownText.anchor.set(0.5, 0.5); countdownText.x = 1024; countdownText.y = 1200; game.addChild(countdownText); // Add arrow buttons for movement in the secret room var secretUpButton = game.addChild(new ArrowButton('up')); secretUpButton.x = 1024; secretUpButton.y = 2500; var secretDownButton = game.addChild(new ArrowButton('down')); secretDownButton.x = 1024; secretDownButton.y = 2620; var secretLeftButton = game.addChild(new ArrowButton('left')); secretLeftButton.x = 904; secretLeftButton.y = 2560; var secretRightButton = game.addChild(new ArrowButton('right')); secretRightButton.x = 1144; secretRightButton.y = 2560; // Timer for countdown var countdownTimer = LK.setInterval(function () { countdownValue--; if (countdownValue > 0) { countdownText.setText(countdownValue + ''); } else { LK.clearInterval(countdownTimer); // Survived! Show success message for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } game.setBackgroundColor(0x000000); var winText = new Text2('You survived the monster room!\nYou are truly observant.', { size: 100, fill: 0x00ff00 }); winText.anchor.set(0.5, 0.5); winText.x = 1024; winText.y = 1366; game.addChild(winText); } }, 1000); // Override game.update for this room var secretRoomActive = true; game.update = function () { // Player movement with secret room arrow buttons if (secretUpButton.isPressed) { player.y = Math.max(50, player.y - playerSpeed); } if (secretDownButton.isPressed) { player.y = Math.min(2682, player.y + playerSpeed); } if (secretLeftButton.isPressed) { player.x = Math.max(50, player.x - playerSpeed); } if (secretRightButton.isPressed) { player.x = Math.min(1998, player.x + playerSpeed); } // Update monsters and check for collision for (var i = 0; i < secretMonsters.length; i++) { var mon = secretMonsters[i]; if (mon.update) mon.update(); var caught = mon.intersects(player); if (!mon.lastPlayerIntersecting && caught) { // Player caught! End the room and restart the secret room and countdown LK.clearInterval(countdownTimer); for (var j = game.children.length - 1; j >= 0; j--) { game.removeChild(game.children[j]); } game.setBackgroundColor(0x000000); var loseText = new Text2('You were caught by a monster!\nRestarting...', { size: 100, fill: 0xff0000 }); loseText.anchor.set(0.5, 0.5); loseText.x = 1024; loseText.y = 1366; game.addChild(loseText); // Restart secret room after a short delay LK.setTimeout(function () { // Remove lose text for (var k = game.children.length - 1; k >= 0; k--) { game.removeChild(game.children[k]); } game.setBackgroundColor(0x000000); // Show special text again var foundButtonText = new Text2('You found this very small button.\nThis is not the win.\nSurvive the monsters for 10 seconds!', { size: 80, fill: 0xffffff }); foundButtonText.anchor.set(0.5, 0.5); foundButtonText.x = 1024; foundButtonText.y = 500; game.addChild(foundButtonText); // Reset player position player.x = 1024; player.y = 2000; game.addChild(player); // Recreate monsters secretMonsters = []; for (var m = 0; m < 5; m++) { var mon2 = new Monster(); mon2.x = 400 + Math.random() * 1200; mon2.y = 400 + Math.random() * 400; mon2.speed = 2.7 + Math.random() * 0.5; secretMonsters.push(mon2); game.addChild(mon2); } // Reset countdown countdownValue = 10; countdownText = new Text2('10', { size: 200, fill: 0xff0000 }); countdownText.anchor.set(0.5, 0.5); countdownText.x = 1024; countdownText.y = 1200; game.addChild(countdownText); // Re-add arrow buttons secretUpButton = game.addChild(new ArrowButton('up')); secretUpButton.x = 1024; secretUpButton.y = 2500; secretDownButton = game.addChild(new ArrowButton('down')); secretDownButton.x = 1024; secretDownButton.y = 2620; secretLeftButton = game.addChild(new ArrowButton('left')); secretLeftButton.x = 904; secretLeftButton.y = 2560; secretRightButton = game.addChild(new ArrowButton('right')); secretRightButton.x = 1144; secretRightButton.y = 2560; // Restart countdown timer countdownTimer = LK.setInterval(function () { countdownValue--; if (countdownValue > 0) { countdownText.setText(countdownValue + ''); } else { LK.clearInterval(countdownTimer); // Survived! Show success message for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } game.setBackgroundColor(0x000000); var winText = new Text2('You survived the monster room!\nYou are truly observant.', { size: 100, fill: 0x00ff00 }); winText.anchor.set(0.5, 0.5); winText.x = 1024; winText.y = 1366; game.addChild(winText); } }, 1000); secretRoomActive = true; }, 1200); break; } mon.lastPlayerIntersecting = caught; } }; } player.lastFoundEdgeButton = isIntersectingEdgeButton; // --- Monster & Ed button collision logic and monster search mode --- if (monster) { if (monster.lastEdIntersecting === undefined) monster.lastEdIntersecting = false; if (monster.lastWasDead === undefined) monster.lastWasDead = false; if (monster.isSearchingForPlayer === undefined) monster.isSearchingForPlayer = false; if (monster.isGlitchState === undefined) monster.isGlitchState = false; } var isMonsterIntersectingEd = monster ? monster.intersects(edgeButton) : false; // If monster collides with Ed button, enter search mode if (monster && !monster.lastEdIntersecting && isMonsterIntersectingEd && !monster.isSearchingForPlayer && !monster.isGlitchState) { monster.isSearchingForPlayer = true; monster.searchTicks = 0; monster.searchDuration = 600; // 10 seconds at 60fps monster.speed = 7; // Monster runs around quickly // Optional: flash monster to indicate search mode LK.effects.flashObject(monster, 0x00ffff, 800); } // If in search mode, monster runs randomly, not toward player if (monster && monster.isSearchingForPlayer && !monster.isGlitchState) { monster.searchTicks++; // Move in a random direction, change every 30 ticks if (monster.searchDirX === undefined || monster.searchTicks % 30 === 0) { var angle = Math.random() * Math.PI * 2; monster.searchDirX = Math.cos(angle); monster.searchDirY = Math.sin(angle); } monster.x += monster.searchDirX * monster.speed; monster.y += monster.searchDirY * monster.speed; // Clamp to game area monster.x = Math.max(50, Math.min(1998, monster.x)); monster.y = Math.max(50, Math.min(2682, monster.y)); // After search duration, return to normal if (monster.searchTicks > monster.searchDuration) { monster.isSearchingForPlayer = false; monster.speed = 2 + Math.floor((Date.now() - gameStartTime) / 60000); } } // If monster dies (caught by player) while in search mode, show glitch/secret text if (monster && monster.isSearchingForPlayer && !monster.isGlitchState) { var currentIntersecting = monster.intersects(player); if (!monster.lastPlayerIntersecting && currentIntersecting) { monster.isGlitchState = true; // Remove all game elements for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } game.setBackgroundColor(0x000000); var glitchText = new Text2('ERROR: monster is not found\n[404]', { size: 120, fill: 0xff00ff }); glitchText.anchor.set(0.5, 0.5); glitchText.x = 1024; glitchText.y = 1366; game.addChild(glitchText); // Optionally, add a glitch effect LK.effects.flashScreen(0xff00ff, 1200); // Prevent further updates return; } monster.lastPlayerIntersecting = currentIntersecting; } // Track last Ed intersection for next frame monster.lastEdIntersecting = isMonsterIntersectingEd; // --- End Monster & Ed button logic --- // Increase monster speed every minute var elapsedTime = Date.now() - gameStartTime; var minutesPassed = Math.floor(elapsedTime / 60000); // 60000ms = 1 minute var newSpeed = 2 + minutesPassed; // Base speed 2, +1 per minute if (monster.speed !== newSpeed && !monster.isSearchingForPlayer && !monster.isGlitchState) { monster.speed = newSpeed; // Visual feedback when monster gets faster LK.effects.flashObject(monster, 0xff0000, 500); titleText.setText('LEVEL ' + (minutesPassed + 1) + ' - FASTER MONSTER!'); LK.setTimeout(function () { titleText.setText('MONSTER ESCAPE'); }, 2000); // Adjust text scale if monster is huge to prevent glitchy text if (monster.scaleX > 4 || monster.scaleY > 4) { var scaleFix = 1 / Math.max(monster.scaleX, monster.scaleY); titleText.scaleX = scaleFix; titleText.scaleY = scaleFix; instructionsText.scaleX = scaleFix; instructionsText.scaleY = scaleFix; scoreText.scaleX = scaleFix; scoreText.scaleY = scaleFix; // Shake text in place var shakeAmount = 30 * scaleFix; var shakeX = Math.sin(LK.ticks * 0.6) * shakeAmount; var shakeY = Math.cos(LK.ticks * 0.7) * shakeAmount; titleText.x = 1024 + shakeX; instructionsText.x = 1024 + Math.sin(LK.ticks * 0.8 + 1) * shakeAmount; scoreText.x = 1024 + Math.cos(LK.ticks * 0.9 + 2) * shakeAmount; titleText.y = 100 + shakeY; instructionsText.y = 200 + Math.cos(LK.ticks * 0.5 + 3) * shakeAmount; scoreText.y = 300 + Math.sin(LK.ticks * 0.4 + 4) * shakeAmount; } else if (isDistortedUI) { // Heavy distortion for all UI/text // Randomize scale, rotation, and position every frame var distort = function distort(txt, baseX, baseY, baseSize) { txt.scaleX = 0.7 + Math.sin(LK.ticks * 0.13 + Math.random()) * 1.2; txt.scaleY = 0.7 + Math.cos(LK.ticks * 0.17 + Math.random()) * 1.2; txt.rotation = Math.sin(LK.ticks * 0.11 + Math.random()) * 1.5; txt.x = baseX + Math.sin(LK.ticks * 0.5 + Math.random() * 10) * 120; txt.y = baseY + Math.cos(LK.ticks * 0.6 + Math.random() * 10) * 80; if (txt.setText && typeof txt._originalText === "string") { // Randomly garble text if (Math.random() < 0.2) { var chars = txt._originalText.split(''); for (var i = 0; i < chars.length; i++) { if (Math.random() < 0.2 && chars[i] !== ' ' && chars[i] !== '\n') { chars[i] = String.fromCharCode(33 + Math.floor(Math.random() * 94)); } } txt.setText(chars.join('')); } else { txt.setText(txt._originalText); } } }; // Store original text if not already if (typeof titleText._originalText !== "string") titleText._originalText = "MONSTER ESCAPE"; if (typeof instructionsText._originalText !== "string") instructionsText._originalText = "Survive as long as possible!\nMonster gets faster every minute"; if (typeof scoreText._originalText !== "string") scoreText._originalText = scoreText.text; distort(titleText, 1024, 100, 80); distort(instructionsText, 1024, 200, 40); distort(scoreText, 1024, 300, 50); } else { titleText.scaleX = 1; titleText.scaleY = 1; instructionsText.scaleX = 1; instructionsText.scaleY = 1; scoreText.scaleX = 1; scoreText.scaleY = 1; titleText.x = 1024; instructionsText.x = 1024; scoreText.x = 1024; titleText.y = 100; instructionsText.y = 200; scoreText.y = 300; } } // Increase score based on survival time in milliseconds var millisecondsPerTick = 1000 / 60; LK.setScore(Math.floor(LK.getScore() + millisecondsPerTick)); // Update score display var seconds = Math.floor(LK.getScore() / 1000); var minutes = Math.floor(seconds / 60); var displaySeconds = seconds % 60; if (minutes > 0) { scoreText.setText('Time Survived: ' + minutes + 'm ' + displaySeconds + 's'); } else { scoreText.setText('Time Survived: ' + seconds + 's'); } // Add player trail effect if (LK.ticks % 3 === 0) { // Every 3 frames playerTrail.push({ x: player.x, y: player.y, alpha: 0.7 }); } // Remove old trail points and update existing ones for (var i = playerTrail.length - 1; i >= 0; i--) { playerTrail[i].alpha -= 0.05; if (playerTrail[i].alpha <= 0) { playerTrail.splice(i, 1); } } // knockout logic removed }; // --- Black Room Logic --- var blackRoomPlayer, blackRoomEnemies, blackRoomProjectiles, pizzaBtn, pizzaCooldown, pizzaCooldownText, blackRoomArrowBtns, blackRoomEnemyHealthTexts; function startBlackRoom() { // Remove all game elements for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } game.setBackgroundColor(0x000000); // Setup black room player blackRoomPlayer = new Player(); blackRoomPlayer.x = 1024; blackRoomPlayer.y = 1366; game.addChild(blackRoomPlayer); // Setup enemies blackRoomEnemies = []; blackRoomEnemyHealthTexts = []; var enemyCount = 2 + Math.floor(Math.random() * 2); // 2-3 enemies for (var i = 0; i < enemyCount; i++) { var enemy = new BlackRoomEnemy(); // Place enemies at random edges var edge = Math.floor(Math.random() * 4); if (edge === 0) { enemy.x = 200; enemy.y = 200 + Math.random() * 2200; } else if (edge === 1) { enemy.x = 1848; enemy.y = 200 + Math.random() * 2200; } else if (edge === 2) { enemy.x = 200 + Math.random() * 1648; enemy.y = 200; } else { enemy.x = 200 + Math.random() * 1648; enemy.y = 2532; } game.addChild(enemy); blackRoomEnemies.push(enemy); // Health text var healthText = new Text2('Health: 100%', { size: 48, fill: 0xff0000 }); healthText.anchor.set(0.5, 0.5); healthText.x = enemy.x; healthText.y = enemy.y - 90; game.addChild(healthText); blackRoomEnemyHealthTexts.push(healthText); } // Setup pizza projectiles array blackRoomProjectiles = []; // Add arrow buttons for movement blackRoomArrowBtns = { up: game.addChild(new ArrowButton('up')), down: game.addChild(new ArrowButton('down')), left: game.addChild(new ArrowButton('left')), right: game.addChild(new ArrowButton('right')) }; blackRoomArrowBtns.up.x = 1024; blackRoomArrowBtns.up.y = 2500; blackRoomArrowBtns.down.x = 1024; blackRoomArrowBtns.down.y = 2620; blackRoomArrowBtns.left.x = 904; blackRoomArrowBtns.left.y = 2560; blackRoomArrowBtns.right.x = 1144; blackRoomArrowBtns.right.y = 2560; var blackRoomPlayerSpeed = 7; // Add pizza power button pizzaBtn = new Text2('Use Pizza Wheel', { size: 70, fill: 0xffd700 }); pizzaBtn.anchor.set(0.5, 0.5); pizzaBtn.x = 1024; pizzaBtn.y = 2300; pizzaBtn.interactive = true; pizzaBtn.buttonMode = true; pizzaCooldown = 0; pizzaBtn.down = function () { if (pizzaCooldown > 0) return; // Fire pizza in direction of nearest enemy var nearest = null, minDist = 99999; for (var i = 0; i < blackRoomEnemies.length; i++) { var e = blackRoomEnemies[i]; if (e && !e.isKnockedOut) { var dx = e.x - blackRoomPlayer.x; var dy = e.y - blackRoomPlayer.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < minDist) { minDist = dist; nearest = e; } } } if (nearest) { var angle = Math.atan2(nearest.y - blackRoomPlayer.y, nearest.x - blackRoomPlayer.x); var pizza = new PizzaProjectile(); pizza.x = blackRoomPlayer.x; pizza.y = blackRoomPlayer.y; pizza.angle = angle; blackRoomProjectiles.push(pizza); game.addChild(pizza); pizzaCooldown = 30; // 0.5s cooldown } }; game.addChild(pizzaBtn); // --- Unscrew Attack Button and Logic --- var unscrewBtn = new Text2('Unscrew', { size: 70, fill: 0x00ffff }); unscrewBtn.anchor.set(0.5, 0.5); unscrewBtn.x = 1024; unscrewBtn.y = 2450; unscrewBtn.interactive = true; unscrewBtn.buttonMode = true; game.addChild(unscrewBtn); var unscrewResultText = null; unscrewBtn.down = function () { // Find a random alive enemy var aliveEnemies = []; for (var i = 0; i < blackRoomEnemies.length; i++) { if (blackRoomEnemies[i] && !blackRoomEnemies[i].isKnockedOut) { aliveEnemies.push(blackRoomEnemies[i]); } } if (aliveEnemies.length === 0) return; // Pick a random enemy from alive ones var target = aliveEnemies[Math.floor(Math.random() * aliveEnemies.length)]; // 30% chance to instantly kill if (Math.random() < 0.3) { // Instantly knock out target.health = 0; target.isKnockedOut = true; if (typeof target.takePizzaHit === "function") { // Use the knockout animation and win logic target.takePizzaHit(); } // Show "Instant KO!" text if (unscrewResultText && unscrewResultText.parent) unscrewResultText.parent.removeChild(unscrewResultText); unscrewResultText = new Text2('Instant KO!', { size: 90, fill: 0x00ffff }); unscrewResultText.anchor.set(0.5, 0.5); unscrewResultText.x = target.x; unscrewResultText.y = target.y - 160; game.addChild(unscrewResultText); LK.setTimeout(function () { if (unscrewResultText && unscrewResultText.parent) unscrewResultText.parent.removeChild(unscrewResultText); }, 1200); } else { // Show "Nope, try again!" text if (unscrewResultText && unscrewResultText.parent) unscrewResultText.parent.removeChild(unscrewResultText); unscrewResultText = new Text2('Nope, try again!', { size: 70, fill: 0xff0000 }); unscrewResultText.anchor.set(0.5, 0.5); unscrewResultText.x = target.x; unscrewResultText.y = target.y - 160; game.addChild(unscrewResultText); LK.setTimeout(function () { if (unscrewResultText && unscrewResultText.parent) unscrewResultText.parent.removeChild(unscrewResultText); }, 900); } }; // Add pizza cooldown text pizzaCooldownText = new Text2('', { size: 40, fill: 0xffffff }); pizzaCooldownText.anchor.set(0.5, 0.5); pizzaCooldownText.x = 1024; pizzaCooldownText.y = 2380; game.addChild(pizzaCooldownText); // Add instructions var blackRoomInstr = new Text2('Defeat all enemies!\nUse Pizza Wheel to knock them out (-20% health)', { size: 60, fill: 0xffffff }); blackRoomInstr.anchor.set(0.5, 0.5); blackRoomInstr.x = 1024; blackRoomInstr.y = 400; game.addChild(blackRoomInstr); // Black room update loop game.update = function () { // Player movement if (blackRoomArrowBtns.up.isPressed) blackRoomPlayer.y = Math.max(50, blackRoomPlayer.y - blackRoomPlayerSpeed); if (blackRoomArrowBtns.down.isPressed) blackRoomPlayer.y = Math.min(2682, blackRoomPlayer.y + blackRoomPlayerSpeed); if (blackRoomArrowBtns.left.isPressed) blackRoomPlayer.x = Math.max(50, blackRoomPlayer.x - blackRoomPlayerSpeed); if (blackRoomArrowBtns.right.isPressed) blackRoomPlayer.x = Math.min(1998, blackRoomPlayer.x + blackRoomPlayerSpeed); // Enemies update for (var i = 0; i < blackRoomEnemies.length; i++) { var e = blackRoomEnemies[i]; if (e && e.update) e.update(); // Update health text if (blackRoomEnemyHealthTexts[i]) { blackRoomEnemyHealthTexts[i].x = e.x; blackRoomEnemyHealthTexts[i].y = e.y - 90; var percent = Math.max(0, Math.round(e.health)); blackRoomEnemyHealthTexts[i].setText('Health: ' + percent + '%'); blackRoomEnemyHealthTexts[i].visible = !e.isKnockedOut; } } // Pizza projectiles update for (var i = blackRoomProjectiles.length - 1; i >= 0; i--) { var p = blackRoomProjectiles[i]; if (p && p.update) p.update(); // Check collision with enemies for (var j = 0; j < blackRoomEnemies.length; j++) { var e = blackRoomEnemies[j]; if (e && !e.isKnockedOut && p && p.intersects(e)) { e.takePizzaHit(); // Remove pizza if (p.parent) p.parent.removeChild(p); blackRoomProjectiles.splice(i, 1); break; } } } // Pizza cooldown if (pizzaCooldown > 0) { pizzaCooldown--; pizzaBtn.alpha = 0.5; pizzaCooldownText.setText('Pizza ready in ' + (pizzaCooldown / 60).toFixed(1) + 's'); } else { pizzaBtn.alpha = 1.0; pizzaCooldownText.setText(''); } }; } // Helper to restart main game after black room win function restartMainGame() { // Reset death count and black room state playerDeathCount = 0; blackRoomActive = false; if (typeof deathCountText !== "undefined" && deathCountText) { deathCountText.setText('Deaths: 0'); } // Reload page or re-initialize main game // Remove all game elements for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } game.setBackgroundColor(0xffffff); // Re-initialize main game state // Reset player position if (typeof player === "undefined" || !player) { player = new Player(); } player.x = 1024; player.y = 1366; game.addChild(player); // Reset monster if (typeof monster === "undefined" || !monster) { monster = new Monster(); } monster.x = 200; monster.y = 200; monster.speed = 2; monster.scaleX = 1; monster.scaleY = 1; game.addChild(monster); // Reset tinyMonsters if (typeof tinyMonsters === "undefined") tinyMonsters = []; tinyMonsters.length = 0; // Reset black box hasBlackBox = false; blackBox = null; foundBlackBox = false; // Reset edge button if (typeof edgeButton === "undefined" || !edgeButton) { edgeButton = new Container(); var edgeButtonAsset = edgeButton.attachAsset('edgeButtonGrey', { anchorX: 0.5, anchorY: 0.5, width: 12, height: 12, color: 0x888888, shape: 'box' }); } edgeButton.x = 2048 - 60; edgeButton.y = 1366; game.addChild(edgeButton); // Reset UI if (typeof titleText === "undefined" || !titleText) { titleText = new Text2('MONSTER ESCAPE', { size: 80, fill: 0xFF0000 }); titleText.anchor.set(0.5, 0); } titleText.x = 1024; titleText.y = 100; game.addChild(titleText); if (typeof instructionsText === "undefined" || !instructionsText) { instructionsText = new Text2('Survive as long as possible!\nMonster gets faster every minute', { size: 40, fill: 0x333333 }); instructionsText.anchor.set(0.5, 0); } instructionsText.x = 1024; instructionsText.y = 200; game.addChild(instructionsText); if (typeof scoreText === "undefined" || !scoreText) { scoreText = new Text2('Time Survived: 0ms', { size: 50, fill: 0x000000 }); scoreText.anchor.set(0.5, 0); } scoreText.x = 1024; scoreText.y = 300; game.addChild(scoreText); // Reset player trail if (typeof playerTrail === "undefined") playerTrail = []; playerTrail.length = 0; // Reset arrow buttons if (typeof upButton === "undefined" || !upButton) { upButton = game.addChild(new ArrowButton('up')); } upButton.x = 1024; upButton.y = 2500; if (typeof downButton === "undefined" || !downButton) { downButton = game.addChild(new ArrowButton('down')); } downButton.x = 1024; downButton.y = 2620; if (typeof leftButton === "undefined" || !leftButton) { leftButton = game.addChild(new ArrowButton('left')); } leftButton.x = 904; leftButton.y = 2560; if (typeof rightButton === "undefined" || !rightButton) { rightButton = game.addChild(new ArrowButton('right')); } rightButton.x = 1144; rightButton.y = 2560; playerSpeed = 5; gameStartTime = Date.now(); isDistortedUI = false; // Restore main game update loop game.update = function () { // --- Trick monster at edge logic --- if (tinyMonsters && tinyMonsters.length > 0) { for (var i = 0; i < tinyMonsters.length; i++) { var tmon = tinyMonsters[i]; if (tmon.update) tmon.update(); var caught = tmon.intersects(player); if (!tmon.lastPlayerIntersecting && caught) { var deathSound = LK.getSound('deathSound'); deathSound.volume = 1; deathSound.play(); LK.effects.flashScreen(0xff0000, 1000); LK.setTimeout(function () { player.x = 1024; player.y = 1366; for (var j = 0; j < tinyMonsters.length; j++) { tinyMonsters[j].x = 100 + Math.random() * 1848; tinyMonsters[j].y = 100 + Math.random() * 2532; } gameStartTime = Date.now(); LK.setScore(0); }, 1500); } tmon.lastPlayerIntersecting = caught; } player.lastX = player.x; player.lastY = player.y; if (upButton.isPressed) player.y = Math.max(50, player.y - playerSpeed); if (downButton.isPressed) player.y = Math.min(2682, player.y + playerSpeed); if (leftButton.isPressed) player.x = Math.max(50, player.x - playerSpeed); if (rightButton.isPressed) player.x = Math.min(1998, player.x + playerSpeed); if (LK.ticks % 3 === 0) { playerTrail.push({ x: player.x, y: player.y, alpha: 0.7 }); } for (var i = playerTrail.length - 1; i >= 0; i--) { playerTrail[i].alpha -= 0.05; if (playerTrail[i].alpha <= 0) { playerTrail.splice(i, 1); } } return; } // --- Black Room Death Trigger --- if (!blackRoomActive && playerDeathCount >= 10) { blackRoomActive = true; if (typeof startBlackRoom === "function") startBlackRoom(); return; } player.lastX = player.x; player.lastY = player.y; // --- Glitch Room Movement Sequence Tracking --- if (typeof glitchMoveState === "undefined") { glitchMoveState = { upSpamCount: 0, lastUpTick: 0, lastPlayerY: player.y }; } if (typeof glitchHoldState === "undefined") { glitchHoldState = { isHolding: false, holdStartTick: 0, triggered: false }; } if (typeof game._glitchHoldDownListener === "undefined") { game._glitchHoldDownListener = true; game.down = function (x, y, obj) { if (!glitchHoldState.isHolding) { glitchHoldState.isHolding = true; glitchHoldState.holdStartTick = LK.ticks; glitchHoldState.triggered = false; } if (typeof game._originalDown === "function") game._originalDown(x, y, obj); }; game.up = function (x, y, obj) { glitchHoldState.isHolding = false; glitchHoldState.holdStartTick = 0; glitchHoldState.triggered = false; if (typeof game._originalUp === "function") game._originalUp(x, y, obj); }; } if (glitchHoldState.isHolding && !glitchHoldState.triggered && LK.ticks - glitchHoldState.holdStartTick >= 600) { glitchHoldState.triggered = true; for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } game.setBackgroundColor(0x000000); player.x = 1024; player.y = 1366; game.addChild(player); var glitchMonster = new Monster(); glitchMonster.x = 200; glitchMonster.y = 200; glitchMonster.speed = 4.5; glitchMonster.update = function () { var dx = player.x - this.x + (Math.random() - 0.5) * 60; var dy = player.y - this.y + (Math.random() - 0.5) * 60; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 0) { this.x += dx / dist * this.speed; this.y += dy / dist * this.speed; } this.scaleX = 1.2 + Math.sin(LK.ticks * 0.2) * 0.7 + (Math.random() - 0.5) * 0.3; this.scaleY = 1.2 + Math.cos(LK.ticks * 0.2) * 0.7 + (Math.random() - 0.5) * 0.3; if (this.children[0]) { this.children[0].tint = Math.random() < 0.5 ? 0xff00ff : 0xffffff; } var caught = this.intersects(player); if (!this.lastPlayerIntersecting && caught) { LK.effects.flashScreen(0xff00ff, 1200); var loseText = new Text2('GLITCHY MONSTER CAUGHT YOU!\n[RESTARTING...]', { size: 100, fill: 0xff00ff }); loseText.anchor.set(0.5, 0.5); loseText.x = 1024; loseText.y = 1366; game.addChild(loseText); LK.setTimeout(function () { for (var k = game.children.length - 1; k >= 0; k--) { game.removeChild(game.children[k]); } game.setBackgroundColor(0x000000); player.x = 1024; player.y = 1366; game.addChild(player); game.addChild(glitchMonster); }, 1800); } this.lastPlayerIntersecting = caught; }; game.addChild(glitchMonster); var upButtonG = game.addChild(new ArrowButton('up')); upButtonG.x = 1024; upButtonG.y = 2500; var downButtonG = game.addChild(new ArrowButton('down')); downButtonG.x = 1024; downButtonG.y = 2620; var leftButtonG = game.addChild(new ArrowButton('left')); leftButtonG.x = 904; leftButtonG.y = 2560; var rightButtonG = game.addChild(new ArrowButton('right')); rightButtonG.x = 1144; rightButtonG.y = 2560; var playerSpeedG = 7; game.update = function () { if (upButtonG.isPressed) player.y = Math.max(50, player.y - playerSpeedG); if (downButtonG.isPressed) player.y = Math.min(2682, player.y + playerSpeedG); if (leftButtonG.isPressed) player.x = Math.max(50, player.x - playerSpeedG); if (rightButtonG.isPressed) player.x = Math.min(1998, player.x + playerSpeedG); if (glitchMonster && glitchMonster.update) glitchMonster.update(); var shake = (Math.random() - 0.5) * 30; player.x += (Math.random() - 0.5) * 4; player.y += (Math.random() - 0.5) * 4; game.x = shake; game.y = shake; }; var glitchText = new Text2('GLITCH ROOM\nRUN FROM THE GLITCHY MONSTER!', { size: 80, fill: 0xff00ff }); glitchText.anchor.set(0.5, 0.5); glitchText.x = 1024; glitchText.y = 300; game.addChild(glitchText); } var movedUp = player.lastY - player.y > 9; if (movedUp) { if (LK.ticks - glitchMoveState.lastUpTick > 120) { glitchMoveState.upSpamCount = 0; } glitchMoveState.upSpamCount++; glitchMoveState.lastUpTick = LK.ticks; } else if (LK.ticks - glitchMoveState.lastUpTick > 120) { glitchMoveState.upSpamCount = 0; } if (glitchMoveState.upSpamCount >= 5) { for (var i = game.children.length - 1; i >= 0; i--) { game.removeChild(game.children[i]); } game.setBackgroundColor(0x000000); player.x = 1024; player.y = 1366; game.addChild(player); var glitchMonster = new Monster(); glitchMonster.x = 200; glitchMonster.y = 200; glitchMonster.speed = 4.5; glitchMonster.update = function () { var dx = player.x - this.x + (Math.random() - 0.5) * 60; var dy = player.y - this.y + (Math.random() - 0.5) * 60; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 0) { this.x += dx / dist * this.speed; this.y += dy / dist * this.speed; } this.scaleX = 1.2 + Math.sin(LK.ticks * 0.2) * 0.7 + (Math.random() - 0.5) * 0.3; this.scaleY = 1.2 + Math.cos(LK.ticks * 0.2) * 0.7 + (Math.random() - 0.5) * 0.3; if (this.children[0]) { this.children[0].tint = Math.random() < 0.5 ? 0xff00ff : 0xffffff; } var caught = this.intersects(player); if (!this.lastPlayerIntersecting && caught) { LK.effects.flashScreen(0xff00ff, 1200); var loseText = new Text2('GLITCHY MONSTER CAUGHT YOU!\n[RESTARTING...]', { size: 100, fill: 0xff00ff }); loseText.anchor.set(0.5, 0.5); loseText.x = 1024; loseText.y = 1366; game.addChild(loseText); LK.setTimeout(function () { for (var k = game.children.length - 1; k >= 0; k--) { game.removeChild(game.children[k]); } game.setBackgroundColor(0x000000); player.x = 1024; player.y = 1366; game.addChild(player); game.addChild(glitchMonster); }, 1800); } this.lastPlayerIntersecting = caught; }; game.addChild(glitchMonster); var upButtonG = game.addChild(new ArrowButton('up')); upButtonG.x = 1024; upButtonG.y = 2500; var downButtonG = game.addChild(new ArrowButton('down')); downButtonG.x = 1024; downButtonG.y = 2620; var leftButtonG = game.addChild(new ArrowButton('left')); leftButtonG.x = 904; leftButtonG.y = 2560; var rightButtonG = game.addChild(new ArrowButton('right')); rightButtonG.x = 1144; rightButtonG.y = 2560; var playerSpeedG = 7; game.update = function () { if (upButtonG.isPressed) player.y = Math.max(50, player.y - playerSpeedG); if (downButtonG.isPressed) player.y = Math.min(2682, player.y + playerSpeedG); if (leftButtonG.isPressed) player.x = Math.max(50, player.x - playerSpeedG); if (rightButtonG.isPressed) player.x = Math.min(1998, player.x + playerSpeedG); if (glitchMonster && glitchMonster.update) glitchMonster.update(); var shake = (Math.random() - 0.5) * 30; player.x += (Math.random() - 0.5) * 4; player.y += (Math.random() - 0.5) * 4; game.x = shake; game.y = shake; }; var glitchText = new Text2('GLITCH ROOM\nRUN FROM THE GLITCHY MONSTER!', { size: 80, fill: 0xff00ff }); glitchText.anchor.set(0.5, 0.5); glitchText.x = 1024; glitchText.y = 300; game.addChild(glitchText); glitchMoveState.upSpamCount = -999; } if (upButton.isPressed) player.y = Math.max(50, player.y - playerSpeed); if (downButton.isPressed) player.y = Math.min(2682, player.y + playerSpeed); if (leftButton.isPressed) player.x = Math.max(50, player.x - playerSpeed); if (rightButton.isPressed) player.x = Math.min(1998, player.x + playerSpeed); // ... (rest of the main game update logic, e.g. black box, edge button, monster, etc.) }; }
===================================================================
--- original.js
+++ change.js
@@ -1498,21 +1498,14 @@
game.addChild(loseText);
// --- Track glitch room deaths ---
if (typeof glitchRoomDeathCount === "undefined") glitchRoomDeathCount = 0;
glitchRoomDeathCount++;
- // --- Begin: Glitch Room Player Forced Movement Direction Logic ---
- if (typeof glitchRoomForceMoveDir === "undefined") glitchRoomForceMoveDir = "up";
- if (typeof glitchRoomForceMoveActive === "undefined") glitchRoomForceMoveActive = false;
- if (typeof glitchRoomForceMoveTicks === "undefined") glitchRoomForceMoveTicks = 0;
- // Alternate direction after each death
- if (glitchRoomDeathCount % 2 === 1) {
- glitchRoomForceMoveDir = "up";
- } else {
- glitchRoomForceMoveDir = "down";
- }
- glitchRoomForceMoveActive = true;
- glitchRoomForceMoveTicks = 0;
- // --- End: Glitch Room Player Forced Movement Direction Logic ---
+ // --- Begin: Glitch Room Player Always Up/Down Oscillation ---
+ if (typeof glitchRoomOscDir === "undefined") glitchRoomOscDir = "up";
+ if (typeof glitchRoomOscTicks === "undefined") glitchRoomOscTicks = 0;
+ glitchRoomOscDir = "up";
+ glitchRoomOscTicks = 0;
+ // --- End: Glitch Room Player Always Up/Down Oscillation ---
if (glitchRoomDeathCount === 5) {
// Flash the password for 1ms
var pwText = new Text2('Password: 199268', {
size: 90,
@@ -1537,28 +1530,28 @@
game.addChild(glitchMonster);
// Re-add arrow buttons after restart
glitchRoomButtons = addGlitchRoomArrowButtons();
game.update = function () {
- // --- Begin: Glitch Room Player Forced Movement Direction Logic ---
- if (typeof glitchRoomForceMoveActive !== "undefined" && glitchRoomForceMoveActive) {
- glitchRoomForceMoveTicks++;
- var moveAmount = playerSpeedG;
- if (glitchRoomForceMoveDir === "up") {
- player.y = Math.max(50, player.y - moveAmount);
- } else if (glitchRoomForceMoveDir === "down") {
- player.y = Math.min(2682, player.y + moveAmount);
+ // --- Begin: Glitch Room Player Always Up/Down Oscillation ---
+ if (typeof glitchRoomOscDir === "undefined") glitchRoomOscDir = "up";
+ if (typeof glitchRoomOscTicks === "undefined") glitchRoomOscTicks = 0;
+ var moveAmount = playerSpeedG;
+ if (glitchRoomOscDir === "up") {
+ player.y = Math.max(50, player.y - moveAmount);
+ glitchRoomOscTicks++;
+ if (player.y <= 50 || glitchRoomOscTicks > 60) {
+ glitchRoomOscDir = "down";
+ glitchRoomOscTicks = 0;
}
- // After 120 ticks (~2 seconds), stop forced movement
- if (glitchRoomForceMoveTicks > 120) {
- glitchRoomForceMoveActive = false;
- }
} else {
- if (glitchRoomButtons.up.isPressed) player.y = Math.max(50, player.y - playerSpeedG);
- if (glitchRoomButtons.down.isPressed) player.y = Math.min(2682, player.y + playerSpeedG);
- if (glitchRoomButtons.left.isPressed) player.x = Math.max(50, player.x - playerSpeedG);
- if (glitchRoomButtons.right.isPressed) player.x = Math.min(1998, player.x + playerSpeedG);
+ player.y = Math.min(2682, player.y + moveAmount);
+ glitchRoomOscTicks++;
+ if (player.y >= 2682 || glitchRoomOscTicks > 60) {
+ glitchRoomOscDir = "up";
+ glitchRoomOscTicks = 0;
+ }
}
- // --- End: Glitch Room Player Forced Movement Direction Logic ---
+ // --- End: Glitch Room Player Always Up/Down Oscillation ---
if (glitchMonster && glitchMonster.update) glitchMonster.update();
// Always keep glitchText and backBtn in front of glitchMonster
if (typeof glitchText !== "undefined" && glitchText && typeof game.setChildIndex === "function" && game.children.indexOf(glitchText) !== -1) {
game.setChildIndex(glitchText, game.children.length - 1);
Modern App Store icon, high definition, square with rounded corners, for a game titled "Monster Chase" and with the description "Control a character with your finger while an AI monster hunts you down. Survive as long as possible in this intense chase game with intuitive touch controls.". No text on icon!
Fullscreen modern App Store landscape banner, 16:9, high definition, for a game titled "Monster Chase" and with the description "Control a character with your finger while an AI monster hunts you down. Survive as long as possible in this intense chase game with intuitive touch controls.". No text on banner!