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
});
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
});
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();
mapContainer.x = -monitorBg.width / 2 + 100;
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 () {
// 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'],
'westHall': ['diningArea', 'westCorner', 'officeLeft'],
'eastHall': ['diningArea', 'eastCorner', 'officeRight'],
'westCorner': ['westHall', 'officeLeft'],
'eastCorner': ['eastHall', 'officeRight'],
'kitchen': ['diningArea'],
'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,
'stage': 5
};
// Camera positions on the map
var mapPositions = {
'stage': {
x: 150,
y: 100
},
'diningArea': {
x: 300,
y: 200
},
'westHall': {
x: 100,
y: 300
},
'eastHall': {
x: 500,
y: 300
},
'westCorner': {
x: 100,
y: 400
},
'eastCorner': {
x: 500,
y: 400
},
'kitchen': {
x: 300,
y: 100
},
'officeLeft': {
x: 100,
y: 500
},
'officeRight': {
x: 500,
y: 500
}
};
// Camera positions for rendering animatronics
var cameraPositions = {
'stage': {
x: 0,
y: 0
},
'diningArea': {
x: 50,
y: 0
},
'westHall': {
x: -50,
y: 0
},
'eastHall': {
x: 50,
y: 0
},
'westCorner': {
x: -80,
y: 20
},
'eastCorner': {
x: 80,
y: 20
},
'kitchen': {
x: 0,
y: -30
},
'officeLeft': {
x: -100,
y: 0
},
'officeRight': {
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 = 300;
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);
// 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 second)
if (LK.ticks % 60 === 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(); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,727 @@
-/****
+/****
+* 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
+ });
+ 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
+ });
+ 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();
+ mapContainer.x = -monitorBg.width / 2 + 100;
+ 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 () {
+ // 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
-});
\ No newline at end of file
+});
+
+/****
+* 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'],
+ 'westHall': ['diningArea', 'westCorner', 'officeLeft'],
+ 'eastHall': ['diningArea', 'eastCorner', 'officeRight'],
+ 'westCorner': ['westHall', 'officeLeft'],
+ 'eastCorner': ['eastHall', 'officeRight'],
+ 'kitchen': ['diningArea'],
+ '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,
+ 'stage': 5
+};
+// Camera positions on the map
+var mapPositions = {
+ 'stage': {
+ x: 150,
+ y: 100
+ },
+ 'diningArea': {
+ x: 300,
+ y: 200
+ },
+ 'westHall': {
+ x: 100,
+ y: 300
+ },
+ 'eastHall': {
+ x: 500,
+ y: 300
+ },
+ 'westCorner': {
+ x: 100,
+ y: 400
+ },
+ 'eastCorner': {
+ x: 500,
+ y: 400
+ },
+ 'kitchen': {
+ x: 300,
+ y: 100
+ },
+ 'officeLeft': {
+ x: 100,
+ y: 500
+ },
+ 'officeRight': {
+ x: 500,
+ y: 500
+ }
+};
+// Camera positions for rendering animatronics
+var cameraPositions = {
+ 'stage': {
+ x: 0,
+ y: 0
+ },
+ 'diningArea': {
+ x: 50,
+ y: 0
+ },
+ 'westHall': {
+ x: -50,
+ y: 0
+ },
+ 'eastHall': {
+ x: 50,
+ y: 0
+ },
+ 'westCorner': {
+ x: -80,
+ y: 20
+ },
+ 'eastCorner': {
+ x: 80,
+ y: 20
+ },
+ 'kitchen': {
+ x: 0,
+ y: -30
+ },
+ 'officeLeft': {
+ x: -100,
+ y: 0
+ },
+ 'officeRight': {
+ 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 = 300;
+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);
+// 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 second)
+ if (LK.ticks % 60 === 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();
\ No newline at end of file
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