User prompt
make a scary sound before coming to the door animatronic
User prompt
And I want a terrifying game over screen
User prompt
I want a terrifying jumpscare
User prompt
then create an asset for the character we are moving
User prompt
create an asset that covers the whole office. So I can manage the whole office with one image.
User prompt
Move the left door open/close button further to the right a bit
User prompt
move the left door open/close button further to the right
User prompt
move the left door open/close button further to the right
User prompt
theyre still there remove them, remove the cameras
User prompt
delete easthall-eastcorner-office right cameras
User prompt
kamera alanından taşmış kameraları sil
User prompt
Make the camera area bigger so the rooms fit. Delete or edit the rooms with problems.
User prompt
Some rooms are out of camera range. Put them inside the camera. You can reduce their size.
User prompt
Keep the rooms in the camera separate. Don't make them look cluttered.
User prompt
Add new rooms to the camera
User prompt
Have Animatronics come to the door when he arrives.
User prompt
put them in the lower right corner of the screen
User prompt
add your own arrow keys to the screen and let me move by pressing them.
User prompt
remove the buttons. Add more cameras like kitchen, arcade room etc.
User prompt
I want to change cameras
User prompt
make time passes faster
Code edit (1 edits merged)
Please save this source code
User prompt
Night Shift: Security Alert
Initial prompt
Made me a game like FNAF: Security Breach.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
currentNight: 1,
highestNight: 1
});
/****
* Classes
****/
var Animatronic = Container.expand(function (id, startingRoom, aggressiveness) {
var self = Container.call(this);
self.id = id;
self.currentRoom = startingRoom;
self.previousRoom = startingRoom;
self.aggressiveness = aggressiveness;
self.moveTimer = 0;
self.moveCooldown = Math.floor(600 / self.aggressiveness);
self.active = true;
var sprite = self.attachAsset('animatronic', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.9
});
self.update = function () {
if (!self.active) return;
// Increment move timer
self.moveTimer++;
// Check if it's time to move
if (self.moveTimer >= self.moveCooldown) {
self.moveTimer = 0;
// Determine if animatronic will move based on aggressiveness
if (Math.random() * 100 < self.aggressiveness) {
self.moveToNextRoom();
}
}
};
self.moveToNextRoom = function () {
self.previousRoom = self.currentRoom;
// Get adjacent rooms to current position
var possibleRooms = roomMap[self.currentRoom];
// Choose one at random, with preference to rooms closer to office
var targetRoom;
var randomValue = Math.random();
// As aggressiveness increases, more likely to move toward office
if (randomValue < self.aggressiveness / 100) {
// Try to move toward office
var closerRooms = possibleRooms.filter(function (room) {
return roomDistanceToOffice[room] < roomDistanceToOffice[self.currentRoom];
});
if (closerRooms.length > 0) {
targetRoom = closerRooms[Math.floor(Math.random() * closerRooms.length)];
} else {
targetRoom = possibleRooms[Math.floor(Math.random() * possibleRooms.length)];
}
} else {
// Random movement
targetRoom = possibleRooms[Math.floor(Math.random() * possibleRooms.length)];
}
self.currentRoom = targetRoom;
// If moved to office or right outside office door, check door status
if (self.currentRoom === 'officeLeft' || self.currentRoom === 'officeRight') {
var doorSide = self.currentRoom === 'officeLeft' ? 'left' : 'right';
if (!doors[doorSide].closed) {
// Jumpscare if door is open!
triggerJumpscare(self.id);
}
}
// Notify that an animatronic moved for camera updates
animatronicMoved = true;
};
self.render = function (cameraElement) {
// Position the animatronic in the correct spot based on the camera view
if (self.currentRoom === currentCamera) {
sprite.alpha = 1;
// Position differently based on the room
var roomPosition = cameraPositions[self.currentRoom];
if (roomPosition) {
sprite.x = roomPosition.x;
sprite.y = roomPosition.y;
// Add to the camera feed
cameraElement.addChild(sprite);
}
}
};
return self;
});
var Door = Container.expand(function (side) {
var self = Container.call(this);
self.side = side; // 'left' or 'right'
self.closed = false;
var doorGraphic = self.attachAsset('door', {
anchorX: 0.5,
anchorY: 0.5
});
var doorButton = self.attachAsset('doorButton', {
anchorX: 0.5,
anchorY: 0.5,
y: -250
});
var buttonLabel = new Text2("DOOR", {
size: 20,
fill: 0xFFFFFF
});
buttonLabel.anchor.set(0.5, 0.5);
doorButton.addChild(buttonLabel);
// Door starts open (hidden)
doorGraphic.alpha = 0;
self.toggleDoor = function () {
self.closed = !self.closed;
if (self.closed) {
// Close door
doorGraphic.alpha = 1;
LK.getSound('doorClose').play();
buttonLabel.setText("OPEN");
doorButton.tint = 0xff0000;
// Use power
increasePowerUsage();
} else {
// Open door
doorGraphic.alpha = 0;
LK.getSound('doorOpen').play();
buttonLabel.setText("DOOR");
doorButton.tint = 0x008000;
// Save power
decreasePowerUsage();
// Check if any animatronics are waiting outside
for (var i = 0; i < animatronics.length; i++) {
var dangerRoom = self.side === 'left' ? 'officeLeft' : 'officeRight';
if (animatronics[i].currentRoom === dangerRoom) {
// Jumpscare!
triggerJumpscare(animatronics[i].id);
return;
}
}
}
};
doorButton.down = function () {
self.toggleDoor();
};
return self;
});
var PowerSystem = Container.expand(function () {
var self = Container.call(this);
self.powerLevel = 100;
self.powerUsage = 1; // Base level (always uses some power)
self.drainTimer = 0;
var powerBarBg = self.attachAsset('powerBarBg', {
anchorX: 0,
anchorY: 0.5
});
var powerBar = self.attachAsset('powerBar', {
anchorX: 0,
anchorY: 0.5,
width: 400 // Start at full width
});
var powerLabel = new Text2("POWER: 100%", {
size: 30,
fill: 0xFFFFFF
});
powerLabel.anchor.set(0, 0.5);
powerLabel.x = 420;
self.addChild(powerLabel);
var usageLabel = new Text2("USAGE: ▮", {
size: 30,
fill: 0xFFFFFF
});
usageLabel.anchor.set(0, 0.5);
usageLabel.y = 40;
self.addChild(usageLabel);
self.update = function () {
// Drain power based on usage level and game difficulty
self.drainTimer++;
// Drain every X frames based on current night (higher nights drain faster)
var drainRate = Math.max(15 - currentNight * 2, 5);
if (self.drainTimer >= drainRate) {
self.drainTimer = 0;
self.powerLevel -= self.powerUsage * 0.1;
// Update power bar width
powerBar.width = 400 * (self.powerLevel / 100);
// Update label
powerLabel.setText("POWER: " + Math.floor(self.powerLevel) + "%");
// Change color as power decreases
if (self.powerLevel <= 20) {
powerBar.tint = 0xff0000; // Red when low
// Warning sounds when power is very low
if (self.powerLevel <= 10 && self.drainTimer % 5 === 0) {
LK.getSound('warning').play();
}
} else if (self.powerLevel <= 50) {
powerBar.tint = 0xffff00; // Yellow when medium
}
// Check for power out
if (self.powerLevel <= 0) {
powerOut();
}
}
};
self.updateUsageDisplay = function () {
var usageText = "USAGE: ";
for (var i = 0; i < self.powerUsage; i++) {
usageText += "▮";
}
usageLabel.setText(usageText);
};
return self;
});
var SecurityCamera = Container.expand(function (roomId, x, y) {
var self = Container.call(this);
self.roomId = roomId;
self.x = x;
self.y = y;
self.isActive = false;
var cameraFeed = self.attachAsset('camFeed', {
anchorX: 0.5,
anchorY: 0.5,
width: 120,
height: 112.5
});
var roomLabel = new Text2(roomId.toUpperCase(), {
size: 24,
fill: 0xFF0000
});
roomLabel.anchor.set(0.5, 0);
roomLabel.y = -cameraFeed.height / 2 - 30;
self.addChild(roomLabel);
var staticOverlay = self.attachAsset('staticOverlay', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.3,
width: 120,
height: 80
});
self.activate = function () {
self.isActive = true;
LK.getSound('camSwitch').play();
// Increase static effect briefly
tween(staticOverlay, {
alpha: 0.7
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(staticOverlay, {
alpha: 0.3
}, {
duration: 300,
easing: tween.easeIn
});
}
});
// Update camera with animatronics in this room
self.updateAnimatronics();
};
self.deactivate = function () {
self.isActive = false;
// Clear any animatronics from view
// (Just reset the camera feed)
while (cameraFeed.children.length > 0) {
cameraFeed.removeChild(cameraFeed.children[0]);
}
};
self.updateAnimatronics = function () {
// Clear previous animatronics
while (cameraFeed.children.length > 0) {
cameraFeed.removeChild(cameraFeed.children[0]);
}
// Add animatronics that are in this room
for (var i = 0; i < animatronics.length; i++) {
if (animatronics[i].currentRoom === self.roomId && self.isActive) {
animatronics[i].render(cameraFeed);
}
}
};
self.down = function () {
// When this camera is clicked, make it the active camera
if (cameraSystemActive && self.roomId !== currentCamera) {
switchCamera(self.roomId);
}
};
return self;
});
var SecurityMonitor = Container.expand(function () {
var self = Container.call(this);
var monitorBg = self.attachAsset('securityMonitor', {
anchorX: 0.5,
anchorY: 0.5
});
var mapContainer = new Container();
// Center the map in the monitor background
mapContainer.x = -monitorBg.width / 2 + 200;
mapContainer.y = -monitorBg.height / 2 + 100;
self.addChild(mapContainer);
var cameraViewContainer = new Container();
cameraViewContainer.x = 200;
cameraViewContainer.y = 0;
self.addChild(cameraViewContainer);
var activeCamera = null;
var cameraLabel = new Text2("CAMERA: NONE", {
size: 40,
fill: 0xFF0000
});
cameraLabel.anchor.set(0.5, 0);
cameraLabel.x = 200;
cameraLabel.y = -monitorBg.height / 2 + 50;
self.addChild(cameraLabel);
var closeButton = self.attachAsset('doorButton', {
anchorX: 0.5,
anchorY: 0.5,
x: monitorBg.width / 2 - 50,
y: -monitorBg.height / 2 + 50,
tint: 0xff0000
});
var closeLabel = new Text2("X", {
size: 40,
fill: 0xFFFFFF
});
closeLabel.anchor.set(0.5, 0.5);
closeButton.addChild(closeLabel);
closeButton.down = function () {
toggleCameraSystem();
};
self.setup = function () {
// Optionally: Draw lines or dots to visually separate rooms (spacer lines)
// We'll use simple rectangles as spacers between clusters of rooms
// (This is a visual aid, not interactive)
var roomGroups = [['stage', 'kitchen', 'diningArea', 'laundry', 'storage'], ['arcade', 'partyRoom', 'backstage', 'restroom'], ['westHall', 'westCorner', 'officeLeft'], ['eastHall', 'eastCorner', 'officeRight']];
// Draw spacers between groups
for (var g = 1; g < roomGroups.length; g++) {
var prevGroup = roomGroups[g - 1];
var currGroup = roomGroups[g];
// Find center of last room in prev group and first room in curr group
var prevRoom = prevGroup[prevGroup.length - 1];
var currRoom = currGroup[0];
var prevPos = mapPositions[prevRoom];
var currPos = mapPositions[currRoom];
if (prevPos && currPos) {
var spacer = new Container();
var line = spacer.attachAsset('powerBarBg', {
anchorX: 0,
anchorY: 0.5,
width: Math.abs(currPos.x - prevPos.x),
height: 10,
tint: 0x222222,
alpha: 0.5
});
spacer.x = Math.min(prevPos.x, currPos.x);
spacer.y = (prevPos.y + currPos.y) / 2;
mapContainer.addChild(spacer);
}
}
// Create cameras for each room
for (var room in cameraPositions) {
var pos = mapPositions[room] || {
x: 0,
y: 0
};
var camera = new SecurityCamera(room, pos.x, pos.y);
mapContainer.addChild(camera);
cameras[room] = camera;
}
// Set initial camera to show
self.switchCamera('stage');
};
self.switchCamera = function (roomId) {
// Deactivate current camera
if (activeCamera) {
activeCamera.deactivate();
}
// Activate new camera
activeCamera = cameras[roomId];
if (activeCamera) {
activeCamera.activate();
currentCamera = roomId;
cameraLabel.setText("CAMERA: " + roomId.toUpperCase());
}
};
self.updateCameras = function () {
if (activeCamera) {
activeCamera.updateAnimatronics();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Game constants and settings
var currentNight = storage.currentNight || 1;
var gameTime = 0; // in seconds
var nightDuration = 360; // 6 minutes per night
var cameraSystemActive = false;
var currentCamera = 'stage';
var animatronicMoved = false;
var gameOver = false;
var powerOutTriggered = false;
// Room layout definitions
var roomMap = {
'stage': ['diningArea'],
'diningArea': ['stage', 'westHall', 'eastHall', 'kitchen', 'arcade', 'partyRoom', 'laundry', 'backstage'],
'westHall': ['diningArea', 'westCorner', 'officeLeft', 'storage', 'laundry'],
'eastHall': ['diningArea', 'eastCorner', 'officeRight', 'arcade'],
'westCorner': ['westHall', 'officeLeft'],
'eastCorner': ['eastHall', 'officeRight'],
'kitchen': ['diningArea', 'storage', 'laundry'],
'arcade': ['diningArea', 'eastHall', 'partyRoom'],
'partyRoom': ['diningArea', 'arcade', 'storage', 'backstage'],
'storage': ['westHall', 'kitchen', 'partyRoom', 'laundry'],
'laundry': ['storage', 'kitchen', 'westHall', 'diningArea'],
'backstage': ['partyRoom', 'diningArea'],
// 'restroom' removed
'officeLeft': ['westCorner', 'office'],
'officeRight': ['eastCorner', 'office'],
'office': ['officeLeft', 'officeRight']
};
// Distance from each room to the office (for AI pathfinding)
var roomDistanceToOffice = {
'office': 0,
'officeLeft': 1,
'officeRight': 1,
'westCorner': 2,
'eastCorner': 2,
'westHall': 3,
'eastHall': 3,
'diningArea': 4,
'kitchen': 5,
'arcade': 5,
'partyRoom': 5,
'storage': 6,
'laundry': 6,
'backstage': 6,
'stage': 6
};
// Camera positions on the map (expanded area, problematic rooms adjusted/removed)
var mapPositions = {
'stage': {
x: 200,
y: 200
},
'diningArea': {
x: 500,
y: 200
},
'kitchen': {
x: 800,
y: 200
},
'laundry': {
x: 1100,
y: 200
},
'storage': {
x: 200,
y: 500
},
'partyRoom': {
x: 500,
y: 500
},
'arcade': {
x: 800,
y: 500
},
'backstage': {
x: 1100,
y: 500
},
// 'restroom' removed for clarity and space (no camera will be created for restroom)
'westHall': {
x: 200,
y: 800
},
// 'eastHall', 'eastCorner', and 'officeRight' removed from mapPositions to prevent their camera creation
'westCorner': {
x: 200,
y: 1100
},
'officeLeft': {
x: 200,
y: 1400
}
};
// Camera positions for rendering animatronics
var cameraPositions = {
'stage': {
x: 0,
y: 0
},
'diningArea': {
x: 50,
y: 0
},
'westHall': {
x: -50,
y: 0
},
// 'eastHall', 'eastCorner', and 'officeRight' removed from cameraPositions to prevent animatronic rendering in those rooms
'westCorner': {
x: -80,
y: 20
},
'kitchen': {
x: 0,
y: -30
},
'arcade': {
x: 60,
y: -20
},
'partyRoom': {
x: 0,
y: 40
},
'storage': {
x: -60,
y: -40
},
'laundry': {
x: -30,
y: -60
},
'backstage': {
x: 100,
y: -50
},
// (restroom removed to prevent out-of-bounds camera)
'officeLeft': {
x: -100,
y: 0
}
};
// Initialize game objects
var office = new Container();
var securityMonitor = new SecurityMonitor();
var powerSystem = new PowerSystem();
var doors = {
'left': new Door('left'),
'right': new Door('right')
};
var cameras = {};
var animatronics = [];
var clockDisplay, nightDisplay, cameraToggleBtn;
// Initialize background
var officeBackground = game.addChild(LK.getAsset('officeBackground', {
anchorX: 0.5,
anchorY: 0,
y: 600
}));
// Add elements to the game
game.addChild(office);
office.y = 1200;
// Position and add doors
doors.left.x = 500; // moved further to the right from 300 to 500
doors.right.x = 1748; // 2048 - 300
office.addChild(doors.left);
office.addChild(doors.right);
// Add security monitor (initially hidden)
securityMonitor.visible = false;
securityMonitor.y = 1300;
game.addChild(securityMonitor);
// Camera navigation buttons
var cameraRoomOrder = ['stage', 'diningArea', 'kitchen', 'laundry', 'storage', 'partyRoom', 'arcade', 'backstage', 'westHall', 'westCorner', 'officeLeft'];
// easthall, eastcorner, and officeRight removed from cameraRoomOrder to delete their cameras
function getCurrentCameraIndex() {
for (var i = 0; i < cameraRoomOrder.length; i++) {
if (cameraRoomOrder[i] === currentCamera) return i;
}
return 0;
}
// Set up camera button
cameraToggleBtn = LK.getAsset('cameraButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2200
});
game.addChild(cameraToggleBtn);
var cameraLabel = new Text2("CAMERAS", {
size: 30,
fill: 0xFFFFFF
});
cameraLabel.anchor.set(0.5, 0.5);
cameraToggleBtn.addChild(cameraLabel);
// Set up power display
powerSystem.x = 150;
powerSystem.y = 150;
LK.gui.topLeft.addChild(powerSystem);
// Set up clock
clockDisplay = new Text2("12:00 AM", {
size: 60,
fill: 0xFFFFFF
});
clockDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(clockDisplay);
// Set up night display
nightDisplay = new Text2("NIGHT " + currentNight, {
size: 60,
fill: 0xFFFFFF
});
nightDisplay.anchor.set(1, 0);
nightDisplay.x = -150;
LK.gui.topRight.addChild(nightDisplay);
// Night overlay for transitions
var nightOverlay = LK.getAsset('nightOverlay', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
alpha: 1
});
game.addChild(nightOverlay);
// Initialize animatronics based on current night
function setupAnimatronics() {
animatronics = [];
// Clear any existing animatronics
for (var i = 0; i < animatronics.length; i++) {
if (animatronics[i].parent) {
animatronics[i].parent.removeChild(animatronics[i]);
}
}
// All animatronics start on the stage
var baseAggressiveness = 5 + currentNight * 5; // Increases each night
// Add animatronics based on night
animatronics.push(new Animatronic('freddy', 'stage', baseAggressiveness));
if (currentNight >= 2) {
animatronics.push(new Animatronic('bonnie', 'stage', baseAggressiveness + 5));
}
if (currentNight >= 3) {
animatronics.push(new Animatronic('chica', 'stage', baseAggressiveness + 2));
}
if (currentNight >= 4) {
animatronics.push(new Animatronic('foxy', 'westHall', baseAggressiveness + 10));
}
}
// Function to start a new night
function startNight() {
// Reset game state
gameTime = 0;
cameraSystemActive = false;
currentCamera = 'stage';
animatronicMoved = false;
gameOver = false;
powerOutTriggered = false;
// Reset doors
doors.left.closed = false;
doors.right.closed = false;
doors.left.toggleDoor();
doors.left.toggleDoor();
doors.right.toggleDoor();
doors.right.toggleDoor();
// Reset power
powerSystem.powerLevel = 100;
powerSystem.powerUsage = 1;
powerSystem.updateUsageDisplay();
// Setup security cameras
securityMonitor.setup();
// Setup animatronics
setupAnimatronics();
// Update display
nightDisplay.setText("NIGHT " + currentNight);
// Fade in
tween(nightOverlay, {
alpha: 0
}, {
duration: 2000,
easing: tween.easeIn
});
// Play ambient sounds
LK.playMusic('ambientMusic', {
loop: true
});
LK.getSound('ambient').play();
}
// Function to toggle camera system
function toggleCameraSystem() {
cameraSystemActive = !cameraSystemActive;
if (cameraSystemActive) {
// Show camera system
securityMonitor.visible = true;
cameraToggleBtn.tint = 0xff0000;
// Use more power
increasePowerUsage();
// Play sound
LK.getSound('camSwitch').play();
} else {
// Hide camera system
securityMonitor.visible = false;
cameraToggleBtn.tint = 0x990000;
// Use less power
decreasePowerUsage();
// Play sound
LK.getSound('camSwitch').play();
}
}
// Function to switch camera views
function switchCamera(roomId) {
securityMonitor.switchCamera(roomId);
// Play sound
LK.getSound('camSwitch').play();
}
// Function to increase power usage
function increasePowerUsage() {
powerSystem.powerUsage++;
powerSystem.updateUsageDisplay();
}
// Function to decrease power usage
function decreasePowerUsage() {
if (powerSystem.powerUsage > 1) {
powerSystem.powerUsage--;
powerSystem.updateUsageDisplay();
}
}
// Function to handle power outage
function powerOut() {
if (powerOutTriggered) return;
powerOutTriggered = true;
// Turn off all systems
securityMonitor.visible = false;
cameraSystemActive = false;
// Open all doors
if (doors.left.closed) doors.left.toggleDoor();
if (doors.right.closed) doors.right.toggleDoor();
// Play power down sound
LK.getSound('powerDown').play();
// Game over with slight delay (for tension)
LK.setTimeout(function () {
triggerJumpscare('freddy');
}, 5000);
}
// Function to trigger jumpscare
function triggerJumpscare(animatronicId) {
if (gameOver) return;
gameOver = true;
// Play jumpscare sound
LK.getSound('jumpscare').play();
// Flash screen red
LK.effects.flashScreen(0xff0000, 500);
// Show game over after a brief delay
LK.setTimeout(function () {
LK.showGameOver();
}, 1000);
}
// Function to complete the night successfully
function completeNight() {
// Update stored progress
if (currentNight >= storage.highestNight) {
storage.highestNight = currentNight + 1;
}
currentNight++;
storage.currentNight = currentNight;
// Show win screen
LK.showYouWin();
}
// Events for camera toggle button
cameraToggleBtn.down = function () {
toggleCameraSystem();
};
// Update game time and clock display
function updateClock() {
var hour = Math.floor(gameTime / 60) + 12;
if (hour > 12) hour -= 12;
var timeString = hour + ":00 AM";
clockDisplay.setText(timeString);
// Check if night is complete
if (gameTime >= nightDuration) {
completeNight();
}
}
// Main game update function
game.update = function () {
if (nightOverlay.alpha > 0) return; // Don't update while fading in
// Update game time (every half second, so time passes 2x faster)
if (LK.ticks % 30 === 0) {
gameTime++;
updateClock();
}
// Update power system
powerSystem.update();
// Update all animatronics
for (var i = 0; i < animatronics.length; i++) {
animatronics[i].update();
}
// Update camera feed if an animatronic moved
if (animatronicMoved) {
animatronicMoved = false;
securityMonitor.updateCameras();
}
};
// Start the game
startNight();
;
// --- On-screen Arrow Keys for Player Movement ---
// Arrow key asset sizes and positions
var arrowSize = 180;
var arrowAlpha = 0.7;
var arrowY = 2732 - 250;
var arrowXCenter = 2048 / 2;
var arrowSpacing = 220;
// Create arrow containers
var leftArrow = new Container();
var rightArrow = new Container();
var upArrow = new Container();
var downArrow = new Container();
// Add arrow graphics
var leftArrowGraphic = leftArrow.attachAsset('doorButton', {
anchorX: 0.5,
anchorY: 0.5,
width: arrowSize,
height: arrowSize,
tint: 0x4444ff,
alpha: arrowAlpha
});
var rightArrowGraphic = rightArrow.attachAsset('doorButton', {
anchorX: 0.5,
anchorY: 0.5,
width: arrowSize,
height: arrowSize,
tint: 0x4444ff,
alpha: arrowAlpha
});
var upArrowGraphic = upArrow.attachAsset('doorButton', {
anchorX: 0.5,
anchorY: 0.5,
width: arrowSize,
height: arrowSize,
tint: 0x4444ff,
alpha: arrowAlpha
});
var downArrowGraphic = downArrow.attachAsset('doorButton', {
anchorX: 0.5,
anchorY: 0.5,
width: arrowSize,
height: arrowSize,
tint: 0x4444ff,
alpha: arrowAlpha
});
// Add arrow labels
var leftLabel = new Text2("◀", {
size: 100,
fill: 0xFFFFFF
});
leftLabel.anchor.set(0.5, 0.5);
leftArrow.addChild(leftLabel);
var rightLabel = new Text2("▶", {
size: 100,
fill: 0xFFFFFF
});
rightLabel.anchor.set(0.5, 0.5);
rightArrow.addChild(rightLabel);
var upLabel = new Text2("▲", {
size: 100,
fill: 0xFFFFFF
});
upLabel.anchor.set(0.5, 0.5);
upArrow.addChild(upLabel);
var downLabel = new Text2("▼", {
size: 100,
fill: 0xFFFFFF
});
downLabel.anchor.set(0.5, 0.5);
downArrow.addChild(downLabel);
// Position arrows (bottom center, spaced out)
leftArrow.x = arrowXCenter - arrowSpacing;
leftArrow.y = arrowY;
rightArrow.x = arrowXCenter + arrowSpacing;
rightArrow.y = arrowY;
upArrow.x = arrowXCenter;
upArrow.y = arrowY - arrowSpacing;
downArrow.x = arrowXCenter;
downArrow.y = arrowY + arrowSpacing / 1.5;
// Add to game
game.addChild(leftArrow);
game.addChild(rightArrow);
game.addChild(upArrow);
game.addChild(downArrow);
// --- Player movement logic ---
// Define player position in the office (for demo, just a dot in the office)
if (typeof playerPos === "undefined") {
var playerPos = {
x: 2048 / 2,
y: 1800
};
}
if (typeof playerDot === "undefined") {
var playerDot = new Container();
var dotGraphic = playerDot.attachAsset('securityCamera', {
anchorX: 0.5,
anchorY: 0.5,
width: 80,
height: 80,
tint: 0xffff00,
alpha: 1
});
playerDot.x = playerPos.x;
playerDot.y = playerPos.y;
game.addChild(playerDot);
}
// Movement boundaries (keep player in office area)
var minX = 300 + 80,
maxX = 1748 - 80;
var minY = 1200 + 80,
maxY = 1200 + 600 - 80;
// Move player and update dot position
function movePlayer(dx, dy) {
playerPos.x += dx;
playerPos.y += dy;
// Clamp to bounds
if (playerPos.x < minX) playerPos.x = minX;
if (playerPos.x > maxX) playerPos.x = maxX;
if (playerPos.y < minY) playerPos.y = minY;
if (playerPos.y > maxY) playerPos.y = maxY;
playerDot.x = playerPos.x;
playerDot.y = playerPos.y;
// --- Animatronic comes to the door when player arrives ---
// Define door trigger areas (left and right)
var doorTriggerYMin = 1200 + 200;
var doorTriggerYMax = 1200 + 600 - 200;
var leftDoorX = 300;
var rightDoorX = 1748;
var doorTriggerDist = 100;
// Check if player is at left door
if (playerPos.x >= leftDoorX - doorTriggerDist && playerPos.x <= leftDoorX + doorTriggerDist && playerPos.y >= doorTriggerYMin && playerPos.y <= doorTriggerYMax) {
// Move a random animatronic to officeLeft if not already there
for (var i = 0; i < animatronics.length; i++) {
if (animatronics[i].currentRoom !== 'officeLeft') {
animatronics[i].currentRoom = 'officeLeft';
animatronicMoved = true;
break;
}
}
}
// Check if player is at right door
if (playerPos.x >= rightDoorX - doorTriggerDist && playerPos.x <= rightDoorX + doorTriggerDist && playerPos.y >= doorTriggerYMin && playerPos.y <= doorTriggerYMax) {
// Move a random animatronic to officeRight if not already there
for (var i = 0; i < animatronics.length; i++) {
if (animatronics[i].currentRoom !== 'officeRight') {
animatronics[i].currentRoom = 'officeRight';
animatronicMoved = true;
break;
}
}
}
}
// Arrow key event handlers
leftArrow.down = function () {
movePlayer(-100, 0);
};
rightArrow.down = function () {
movePlayer(100, 0);
};
upArrow.down = function () {
movePlayer(0, -100);
};
downArrow.down = function () {
movePlayer(0, 100);
}; ===================================================================
--- original.js
+++ change.js
@@ -559,9 +559,9 @@
// Add elements to the game
game.addChild(office);
office.y = 1200;
// Position and add doors
-doors.left.x = 300;
+doors.left.x = 500; // moved further to the right from 300 to 500
doors.right.x = 1748; // 2048 - 300
office.addChild(doors.left);
office.addChild(doors.right);
// Add security monitor (initially hidden)
A terrifying very big animatronic.. In-Game asset. 2d. High contrast. No shadows
It says Night 1. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
make a red door open and close button. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
nothing. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Bana bir ofis odası yap. Biraz gerilim salan ama içinde canavar olmayan eski bir karanlık güvenlik ofis odası gibi olsun. In-Game asset. 2d. High contrast. No shadows
A 30-something security guard in a purple uniform, looking tired and vengeful.. In-Game asset. 2d. High contrast. No shadows