User prompt
El animatronico tenga un cuerpo
User prompt
Pon le forma de oso y de conejo y pato
User prompt
Pon les formas
User prompt
La carga dure mas
User prompt
Mejora a bunny y a freddy y a chica ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Mejorar la grafica y las luces y animatronicos ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Mejorar los botones
User prompt
Dinamicas
User prompt
Please fix the bug: 'tween.to is not a function' in or related to this line: 'tween.to(ambientLight, {' Line Number: 808 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
God grafics
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'fill')' in or related to this line: 'statusText.style.fill = 0xff0000;' Line Number: 582
User prompt
Characters
User prompt
Add animatronics
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toGlobal')' in or related to this line: 'var localPos = self.toLocal(obj.parent.toGlobal(obj.position));' Line Number: 405
User prompt
Add security
User prompt
Add a doors
User prompt
add a mask a
User prompt
Add fredy and chica
Code edit (1 edits merged)
Please save this source code
User prompt
Five Nights a Bunny
Initial prompt
Five nights a bunny
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var BalloonBoy = Container.expand(function () {
var self = Container.call(this);
var bbGraphics = self.attachAsset('chica', {
anchorX: 0.5,
anchorY: 1.0
});
bbGraphics.tint = 0x4169E1; // Blue tint for Balloon Boy
bbGraphics.scaleX = 0.7; // Smaller than other animatronics
bbGraphics.scaleY = 0.7;
self.currentRoom = 'gameArea';
self.moveTimer = 0;
self.moveDelay = 300;
self.isInVent = false;
self.ventTimer = 0;
self.hasDisabledFlashlight = false;
self.move = function () {
if (self.isInVent) return;
var moveChance = 0.05 + currentNight * 0.06;
if (Math.random() < moveChance) {
var rooms = ['gameArea', 'leftVent', 'rightVent'];
var newRoom = rooms[Math.floor(Math.random() * rooms.length)];
self.currentRoom = newRoom;
// Enter office through vents
if (self.currentRoom === 'leftVent' || self.currentRoom === 'rightVent') {
self.isInVent = true;
self.ventTimer = 180; // 3 seconds to crawl through
}
}
};
self.update = function () {
self.moveTimer++;
if (self.moveTimer >= self.moveDelay) {
self.moveTimer = 0;
self.move();
}
if (self.isInVent) {
self.ventTimer--;
if (self.ventTimer <= 0) {
// BB enters office and disables flashlight
self.currentRoom = 'office';
self.isInVent = false;
self.hasDisabledFlashlight = true;
// Player can no longer use flashlight effectively
}
}
};
return self;
});
var Bonnie = Container.expand(function () {
var self = Container.call(this);
var bonnieGraphics = self.attachAsset('chica', {
anchorX: 0.5,
anchorY: 1.0
});
bonnieGraphics.tint = 0x4169E1; // Blue tint for Bonnie
self.currentRoom = 'stage';
self.moveTimer = 0;
self.moveDelay = 320; // Medium-slow speed
self.isAtDoor = false;
self.doorSide = '';
self.isHiding = false;
self.hideTimer = 0;
self.rooms = ['stage', 'hall', 'dining', 'leftHall', 'backstage'];
self.move = function () {
if (self.isAtDoor || self.isHiding) return;
// Bonnie AI - prefers left side, can hide from cameras
var moveChance = 0.07 + currentNight * 0.07;
if (Math.random() < moveChance) {
var newRoom = self.rooms[Math.floor(Math.random() * self.rooms.length)];
self.currentRoom = newRoom;
// Sometimes hide from cameras
if (Math.random() < 0.3) {
self.isHiding = true;
self.hideTimer = 180; // Hide for 3 seconds
}
// Bonnie only approaches left door
if (self.currentRoom === 'leftHall') {
self.isAtDoor = true;
self.doorSide = 'left';
self.attackTimer = 190; // 3.1 seconds to close door
}
}
};
self.update = function () {
self.moveTimer++;
if (self.moveTimer >= self.moveDelay) {
self.moveTimer = 0;
self.move();
}
if (self.isHiding) {
self.hideTimer--;
if (self.hideTimer <= 0) {
self.isHiding = false;
}
}
if (self.isAtDoor) {
self.attackTimer--;
if (self.attackTimer <= 0) {
// Check if door is closed
var door = leftDoor; // Bonnie only uses left door
if (door.isOpen) {
// Jumpscare!
triggerJumpscare();
} else {
// Bonnie retreats
self.isAtDoor = false;
self.currentRoom = 'stage';
}
}
}
};
return self;
});
var Bunny = Container.expand(function () {
var self = Container.call(this);
var bunnyGraphics = self.attachAsset('bunny', {
anchorX: 0.5,
anchorY: 1.0
});
self.currentRoom = 'hall';
self.moveTimer = 0;
self.moveDelay = 300; // Frames between moves
self.isAtDoor = false;
self.doorSide = '';
self.rooms = ['hall', 'kitchen', 'dining', 'leftHall', 'rightHall'];
self.move = function () {
if (self.isAtDoor) return;
// Bunny AI - becomes more aggressive each night
var moveChance = 0.1 + currentNight * 0.1;
if (Math.random() < moveChance) {
var newRoom = self.rooms[Math.floor(Math.random() * self.rooms.length)];
self.currentRoom = newRoom;
// Check if bunny reaches door
if (self.currentRoom === 'leftHall' || self.currentRoom === 'rightHall') {
self.isAtDoor = true;
self.doorSide = self.currentRoom === 'leftHall' ? 'left' : 'right';
self.attackTimer = 180; // 3 seconds to close door
}
}
};
self.update = function () {
self.moveTimer++;
if (self.moveTimer >= self.moveDelay) {
self.moveTimer = 0;
self.move();
}
if (self.isAtDoor) {
self.attackTimer--;
if (self.attackTimer <= 0) {
// Check if door is closed or mask is on
var door = self.doorSide === 'left' ? leftDoor : rightDoor;
if (door.isOpen && !hasMask) {
// Jumpscare!
triggerJumpscare();
} else {
// Bunny retreats (fooled by mask or blocked by door)
self.isAtDoor = false;
self.currentRoom = 'hall';
}
}
}
};
return self;
});
var Camera = Container.expand(function (roomName, x, y) {
var self = Container.call(this);
var cameraGraphics = self.attachAsset('camera', {
anchorX: 0.5,
anchorY: 0.5
});
self.roomName = roomName;
self.isActive = false;
self.activate = function () {
if (batteryLevel <= 0) return;
// Deactivate all other cameras
for (var i = 0; i < cameras.length; i++) {
cameras[i].isActive = false;
cameras[i].getChildAt(0).tint = 0xffffff;
}
self.isActive = true;
cameraGraphics.tint = 0x00ff00;
batteryDrain += 1;
currentCamera = self;
LK.getSound('camera').play();
};
self.down = function (x, y, obj) {
self.activate();
};
return self;
});
var Chica = Container.expand(function () {
var self = Container.call(this);
var chicaGraphics = self.attachAsset('chica', {
anchorX: 0.5,
anchorY: 1.0
});
self.currentRoom = 'kitchen';
self.moveTimer = 0;
self.moveDelay = 350; // Medium speed
self.isAtDoor = false;
self.doorSide = '';
self.rooms = ['kitchen', 'dining', 'hall', 'rightHall']; // Chica prefers kitchen/dining area
self.move = function () {
if (self.isAtDoor) return;
// Chica AI - kitchen focused with occasional door approaches
var moveChance = 0.09 + currentNight * 0.09;
if (Math.random() < moveChance) {
var newRoom = self.rooms[Math.floor(Math.random() * self.rooms.length)];
self.currentRoom = newRoom;
// Chica only approaches right door
if (self.currentRoom === 'rightHall') {
self.isAtDoor = true;
self.doorSide = 'right';
self.attackTimer = 160; // 2.7 seconds to close door - faster than others
}
}
};
self.update = function () {
self.moveTimer++;
if (self.moveTimer >= self.moveDelay) {
self.moveTimer = 0;
self.move();
}
if (self.isAtDoor) {
self.attackTimer--;
if (self.attackTimer <= 0) {
// Check if door is closed
var door = rightDoor; // Chica only uses right door
if (door.isOpen) {
// Jumpscare!
triggerJumpscare();
} else {
// Chica retreats
self.isAtDoor = false;
self.currentRoom = 'kitchen';
}
}
}
};
return self;
});
var Door = Container.expand(function (side) {
var self = Container.call(this);
var doorGraphics = self.attachAsset('door', {
anchorX: 0.5,
anchorY: 1.0
});
self.isOpen = true;
self.side = side;
self.toggle = function () {
if (batteryLevel <= 0) return;
self.isOpen = !self.isOpen;
if (self.isOpen) {
doorGraphics.alpha = 0.5;
} else {
doorGraphics.alpha = 1.0;
batteryDrain += 2;
}
LK.getSound('door').play();
};
self.down = function (x, y, obj) {
self.toggle();
};
return self;
});
var Foxy = Container.expand(function () {
var self = Container.call(this);
var foxyGraphics = self.attachAsset('bunny', {
anchorX: 0.5,
anchorY: 1.0
});
foxyGraphics.tint = 0x8B0000; // Dark red tint for Foxy
self.currentRoom = 'pirateCove';
self.moveTimer = 0;
self.moveDelay = 250; // Fast movement
self.isRunning = false;
self.runTimer = 0;
self.aggressionLevel = 0; // Builds up when not watched
self.move = function () {
if (self.isRunning) return;
// Foxy's aggression increases when not being watched
if (currentCamera && currentCamera.roomName === 'pirateCove') {
self.aggressionLevel = Math.max(0, self.aggressionLevel - 2);
} else {
self.aggressionLevel += 1 + currentNight * 0.5;
}
// When aggression is high enough, Foxy runs
if (self.aggressionLevel > 100) {
self.isRunning = true;
self.runTimer = 120; // 2 seconds to close door
self.currentRoom = 'leftHall';
self.aggressionLevel = 0;
}
};
self.update = function () {
self.moveTimer++;
if (self.moveTimer >= self.moveDelay) {
self.moveTimer = 0;
self.move();
}
if (self.isRunning) {
self.runTimer--;
if (self.runTimer <= 0) {
// Check if left door is closed
if (leftDoor.isOpen) {
// Jumpscare!
triggerJumpscare();
} else {
// Foxy bangs on door and returns
self.isRunning = false;
self.currentRoom = 'pirateCove';
batteryDrain += 5; // Penalty for using door against Foxy
}
}
}
};
return self;
});
var Freddy = Container.expand(function () {
var self = Container.call(this);
var freddyGraphics = self.attachAsset('freddy', {
anchorX: 0.5,
anchorY: 1.0
});
self.currentRoom = 'stage';
self.moveTimer = 0;
self.moveDelay = 400; // Slower than bunny initially
self.isAtDoor = false;
self.doorSide = '';
self.rooms = ['stage', 'hall', 'dining', 'kitchen', 'leftHall', 'rightHall'];
self.move = function () {
if (self.isAtDoor) return;
// Freddy AI - more methodical movement pattern
var moveChance = 0.08 + currentNight * 0.08;
if (Math.random() < moveChance) {
var newRoom = self.rooms[Math.floor(Math.random() * self.rooms.length)];
self.currentRoom = newRoom;
// Check if freddy reaches door
if (self.currentRoom === 'leftHall' || self.currentRoom === 'rightHall') {
self.isAtDoor = true;
self.doorSide = self.currentRoom === 'leftHall' ? 'left' : 'right';
self.attackTimer = 200; // 3.3 seconds to close door
}
}
};
self.update = function () {
self.moveTimer++;
if (self.moveTimer >= self.moveDelay) {
self.moveTimer = 0;
self.move();
}
if (self.isAtDoor) {
self.attackTimer--;
if (self.attackTimer <= 0) {
// Check if door is closed or mask is on
var door = self.doorSide === 'left' ? leftDoor : rightDoor;
if (door.isOpen && !hasMask) {
// Jumpscare!
triggerJumpscare();
} else {
// Freddy retreats (fooled by mask or blocked by door)
self.isAtDoor = false;
self.currentRoom = 'stage';
}
}
}
};
return self;
});
var GoldenFreddy = Container.expand(function () {
var self = Container.call(this);
var goldenFreddyGraphics = self.attachAsset('freddy', {
anchorX: 0.5,
anchorY: 1.0
});
goldenFreddyGraphics.tint = 0xFFD700; // Golden tint
self.currentRoom = 'backstage';
self.moveTimer = 0;
self.moveDelay = 800; // Very slow movement
self.isActive = false;
self.teleportChance = 0.001; // Very low chance to activate
self.disappearTimer = 0;
self.move = function () {
// Golden Freddy has a very small chance to appear randomly
if (!self.isActive && Math.random() < self.teleportChance + currentNight * 0.0005) {
self.isActive = true;
self.currentRoom = 'office'; // Teleports directly to office
self.disappearTimer = 300; // 5 seconds before disappearing
}
};
self.update = function () {
self.moveTimer++;
if (self.moveTimer >= self.moveDelay) {
self.moveTimer = 0;
self.move();
}
if (self.isActive) {
self.disappearTimer--;
if (self.disappearTimer <= 0) {
// Check if player is looking at Golden Freddy (in office and not wearing mask)
if (!hasMask && !isCameraMode) {
// Immediate jumpscare
triggerJumpscare();
} else {
// Golden Freddy disappears
self.isActive = false;
self.currentRoom = 'backstage';
}
}
}
};
return self;
});
var Mangle = Container.expand(function () {
var self = Container.call(this);
var mangleGraphics = self.attachAsset('foxy', {
anchorX: 0.5,
anchorY: 1.0
});
mangleGraphics.tint = 0xFF69B4; // Pink and white tint for Mangle
self.currentRoom = 'kidsCove';
self.moveTimer = 0;
self.moveDelay = 280; // Medium speed
self.isOnCeiling = false;
self.dropTimer = 0;
self.staticNoise = false;
self.move = function () {
var moveChance = 0.06 + currentNight * 0.08;
if (Math.random() < moveChance) {
// Mangle can move through ceiling vents
var rooms = ['kidsCove', 'hall', 'leftHall', 'rightHall', 'office'];
var newRoom = rooms[Math.floor(Math.random() * rooms.length)];
self.currentRoom = newRoom;
// Sometimes appears on office ceiling
if (self.currentRoom === 'office') {
self.isOnCeiling = true;
self.dropTimer = 240; // 4 seconds hanging time
self.staticNoise = true;
}
}
};
self.update = function () {
self.moveTimer++;
if (self.moveTimer >= self.moveDelay) {
self.moveTimer = 0;
self.move();
}
if (self.isOnCeiling) {
self.dropTimer--;
// Create static interference with cameras
if (self.staticNoise && isCameraMode) {
batteryDrain += 0.5; // Extra drain from static
}
if (self.dropTimer <= 0) {
// Mangle drops and attacks
triggerJumpscare();
}
}
};
return self;
});
var Puppet = Container.expand(function () {
var self = Container.call(this);
var puppetGraphics = self.attachAsset('bunny', {
anchorX: 0.5,
anchorY: 1.0
});
puppetGraphics.tint = 0x2F2F2F; // Dark gray tint for Puppet
self.currentRoom = 'musicBox';
self.musicBoxLevel = 100;
self.isEscaping = false;
self.escapeTimer = 0;
self.moveDelay = 200; // Fast when escaping
self.update = function () {
var _currentCamera;
// Music box drains over time
if (!isSecurityMode || ((_currentCamera = currentCamera) === null || _currentCamera === void 0 ? void 0 : _currentCamera.roomName) !== 'musicBox') {
self.musicBoxLevel -= 0.1 + currentNight * 0.05;
} else {
// Wind up music box when watching
self.musicBoxLevel = Math.min(100, self.musicBoxLevel + 0.5);
}
if (self.musicBoxLevel <= 0 && !self.isEscaping) {
self.isEscaping = true;
self.escapeTimer = 600; // 10 seconds to reach office
}
if (self.isEscaping) {
self.escapeTimer--;
if (self.escapeTimer <= 0) {
// Puppet reaches office - instant jumpscare regardless of doors/mask
triggerJumpscare();
}
}
};
return self;
});
var SecurityMonitor = Container.expand(function (roomName, x, y) {
var self = Container.call(this);
var monitorGraphics = self.attachAsset('securityMonitor', {
anchorX: 0.5,
anchorY: 0.5
});
self.roomName = roomName;
self.isActive = false;
// Monitor label
var labelText = new Text2(roomName.toUpperCase(), {
size: 20,
fill: 0x00ff00
});
labelText.anchor.set(0.5, 0.5);
labelText.y = -80;
self.addChild(labelText);
// Status indicator
var statusText = new Text2('CLEAR', {
size: 16,
fill: 0x00ff00
});
statusText.anchor.set(0.5, 0.5);
statusText.y = 60;
self.addChild(statusText);
self.updateStatus = function (animatronics) {
var detected = [];
for (var i = 0; i < animatronics.length; i++) {
if (animatronics[i].currentRoom === self.roomName) {
detected.push(animatronics[i].constructor.name);
}
}
if (detected.length > 0) {
statusText.setText('ALERT: ' + detected.join(', '));
statusText.fill = 0xff0000;
monitorGraphics.tint = 0xff4444;
} else {
statusText.setText('CLEAR');
statusText.fill = 0x00ff00;
monitorGraphics.tint = 0xffffff;
}
};
self.down = function (x, y, obj) {
if (batteryLevel <= 0) return;
// Switch to this camera view
if (currentCamera) {
currentCamera.isActive = false;
currentCamera.getChildAt(0).tint = 0xffffff;
}
currentCamera = self;
self.isActive = true;
LK.getSound('security').play();
};
return self;
});
var SecuritySystem = Container.expand(function () {
var self = Container.call(this);
self.isActive = false;
self.lockdownMode = false;
self.systemPower = 100;
// Main security panel background
var panelBg = self.attachAsset('room', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 2.0,
alpha: 0.9
});
panelBg.tint = 0x2a2a2a;
// Security system title
var titleText = new Text2('SECURITY SYSTEM', {
size: 40,
fill: 0x00ff00
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -250;
self.addChild(titleText);
// Lockdown button
var lockdownButton = self.addChild(LK.getAsset('securityButton', {
anchorX: 0.5,
anchorY: 0.5,
x: -100,
y: 200,
scaleX: 1.5,
scaleY: 1.5
}));
var lockdownText = new Text2('LOCKDOWN', {
size: 20,
fill: 0xffffff
});
lockdownText.anchor.set(0.5, 0.5);
lockdownText.y = 200;
lockdownText.x = -100;
self.addChild(lockdownText);
// Emergency lights button
var lightsButton = self.addChild(LK.getAsset('securityButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 100,
y: 200,
scaleX: 1.5,
scaleY: 1.5
}));
var lightsText = new Text2('LIGHTS', {
size: 20,
fill: 0xffffff
});
lightsText.anchor.set(0.5, 0.5);
lightsText.y = 200;
lightsText.x = 100;
self.addChild(lightsText);
// System status
var statusText = new Text2('SYSTEM ONLINE', {
size: 30,
fill: 0x00ff00
});
statusText.anchor.set(0.5, 0.5);
statusText.y = -200;
self.addChild(statusText);
self.activateLockdown = function () {
if (batteryLevel < 20) return; // Requires significant power
self.lockdownMode = !self.lockdownMode;
if (self.lockdownMode) {
// Close all doors and prevent opening
leftDoor.isOpen = false;
rightDoor.isOpen = false;
leftDoor.getChildAt(0).alpha = 1.0;
rightDoor.getChildAt(0).alpha = 1.0;
lockdownButton.tint = 0xff0000;
lockdownText.fill = 0xff0000;
statusText.setText('LOCKDOWN ACTIVE');
statusText.fill = 0xff0000;
batteryDrain += 5; // Heavy power consumption
} else {
lockdownButton.tint = 0xffffff;
lockdownText.fill = 0xffffff;
statusText.setText('SYSTEM ONLINE');
statusText.fill = 0x00ff00;
}
LK.getSound('security').play();
};
self.activateEmergencyLights = function () {
if (batteryLevel < 10) return;
// Flash all areas to temporarily stun animatronics
LK.effects.flashScreen(0xffffff, 500);
// Reset animatronic positions (they retreat)
bunny.isAtDoor = false;
bunny.currentRoom = 'hall';
freddy.isAtDoor = false;
freddy.currentRoom = 'stage';
chica.isAtDoor = false;
chica.currentRoom = 'kitchen';
foxy.isRunning = false;
foxy.currentRoom = 'pirateCove';
foxy.aggressionLevel = 0;
bonnie.isAtDoor = false;
bonnie.isHiding = false;
bonnie.currentRoom = 'stage';
goldenFreddy.isActive = false;
goldenFreddy.currentRoom = 'backstage';
puppet.isEscaping = false;
puppet.musicBoxLevel = 100;
mangle.isOnCeiling = false;
mangle.staticNoise = false;
mangle.currentRoom = 'kidsCove';
balloonBoy.isInVent = false;
balloonBoy.hasDisabledFlashlight = false;
balloonBoy.currentRoom = 'gameArea';
batteryDrain += 8;
LK.getSound('security').play();
};
self.down = function (x, y, obj) {
// Use direct coordinates instead of converting through parent to avoid undefined errors
// Check lockdown button
if (x > -160 && x < -40 && y > 170 && y < 230) {
self.activateLockdown();
}
// Check lights button
if (x > 40 && x < 160 && y > 170 && y < 230) {
self.activateEmergencyLights();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Game state variables
var currentNight = 1;
var nightTimer = 0;
var nightDuration = 28800; // 8 minutes in frames (60fps)
var batteryLevel = 100;
var batteryDrain = 0.5;
var isGameActive = true;
var currentCamera = null;
var hasMask = false;
var maskCooldown = 0;
// UI Elements
var timeText = new Text2('12:00 AM', {
size: 80,
fill: 0xFFFFFF
});
timeText.anchor.set(0.5, 0);
LK.gui.top.addChild(timeText);
var nightText = new Text2('Night 1', {
size: 60,
fill: 0xFFFFFF
});
nightText.anchor.set(0, 0);
nightText.x = 50;
nightText.y = 50;
LK.gui.topLeft.addChild(nightText);
var batteryText = new Text2('Battery: 100%', {
size: 50,
fill: 0x00FF00
});
batteryText.anchor.set(1, 0);
LK.gui.topRight.addChild(batteryText);
// Office setup with enhanced visuals
var office = game.addChild(LK.getAsset('office', {
anchorX: 0.5,
anchorY: 1.0,
x: 1024,
y: 2732
}));
// Add ambient lighting overlay
var ambientLight = game.addChild(LK.getAsset('room', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
scaleX: 5.0,
scaleY: 5.0,
alpha: 0.15
}));
ambientLight.tint = 0x4a4a2a; // Warm dim lighting
// Add depth shadows
var officeShadow = game.addChild(LK.getAsset('office', {
anchorX: 0.5,
anchorY: 1.0,
x: 1030,
y: 2738,
alpha: 0.3
}));
officeShadow.tint = 0x000000;
// Subtle pulsing ambient effect
tween.to(ambientLight, {
alpha: 0.25
}, 3000).yoyo(true).repeat(-1);
// Doors with enhanced graphics
var leftDoor = game.addChild(new Door('left'));
leftDoor.x = 200;
leftDoor.y = 1800;
// Left door shadow
var leftDoorShadow = game.addChild(LK.getAsset('door', {
anchorX: 0.5,
anchorY: 1.0,
x: 206,
y: 1806,
alpha: 0.4
}));
leftDoorShadow.tint = 0x000000;
var rightDoor = game.addChild(new Door('right'));
rightDoor.x = 1848;
rightDoor.y = 1800;
// Right door shadow
var rightDoorShadow = game.addChild(LK.getAsset('door', {
anchorX: 0.5,
anchorY: 1.0,
x: 1854,
y: 1806,
alpha: 0.4
}));
rightDoorShadow.tint = 0x000000;
// Door control buttons
var leftDoorButton = game.addChild(LK.getAsset('door', {
anchorX: 0.5,
anchorY: 0.5,
x: 100,
y: 1600,
scaleX: 0.3,
scaleY: 0.3,
alpha: 0.7
}));
var rightDoorButton = game.addChild(LK.getAsset('door', {
anchorX: 0.5,
anchorY: 0.5,
x: 1948,
y: 1600,
scaleX: 0.3,
scaleY: 0.3,
alpha: 0.7
}));
// Camera system
var cameras = [];
var cameraPanel = game.addChild(LK.getAsset('room', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1000,
alpha: 0
}));
// Create cameras
var hallCamera = game.addChild(new Camera('hall', 1024, 1100));
cameras.push(hallCamera);
var kitchenCamera = game.addChild(new Camera('kitchen', 924, 1100));
cameras.push(kitchenCamera);
var diningCamera = game.addChild(new Camera('dining', 1124, 1100));
cameras.push(diningCamera);
var leftHallCamera = game.addChild(new Camera('leftHall', 824, 1100));
cameras.push(leftHallCamera);
var rightHallCamera = game.addChild(new Camera('rightHall', 1224, 1100));
cameras.push(rightHallCamera);
var stageCamera = game.addChild(new Camera('stage', 724, 1100));
cameras.push(stageCamera);
var pirateCoveCamera = game.addChild(new Camera('pirateCove', 624, 1100));
cameras.push(pirateCoveCamera);
var backstageCamera = game.addChild(new Camera('backstage', 524, 1100));
cameras.push(backstageCamera);
var musicBoxCamera = game.addChild(new Camera('musicBox', 424, 1100));
cameras.push(musicBoxCamera);
var kidsCoveCamera = game.addChild(new Camera('kidsCove', 324, 1100));
cameras.push(kidsCoveCamera);
var gameAreaCamera = game.addChild(new Camera('gameArea', 224, 1100));
cameras.push(gameAreaCamera);
// Security monitoring system
var securityMonitors = [];
var securityPanel = game.addChild(LK.getAsset('room', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 500,
alpha: 0,
scaleX: 2.0,
scaleY: 1.5
}));
// Create security monitors for each room
var hallMonitor = game.addChild(new SecurityMonitor('hall', 824, 400));
securityMonitors.push(hallMonitor);
var kitchenMonitor = game.addChild(new SecurityMonitor('kitchen', 1024, 400));
securityMonitors.push(kitchenMonitor);
var diningMonitor = game.addChild(new SecurityMonitor('dining', 1224, 400));
securityMonitors.push(diningMonitor);
var leftHallMonitor = game.addChild(new SecurityMonitor('leftHall', 724, 500));
securityMonitors.push(leftHallMonitor);
var rightHallMonitor = game.addChild(new SecurityMonitor('rightHall', 1324, 500));
securityMonitors.push(rightHallMonitor);
var stageMonitor = game.addChild(new SecurityMonitor('stage', 924, 500));
securityMonitors.push(stageMonitor);
var pirateCoveMonitor = game.addChild(new SecurityMonitor('pirateCove', 824, 600));
securityMonitors.push(pirateCoveMonitor);
var backstageMonitor = game.addChild(new SecurityMonitor('backstage', 1124, 600));
securityMonitors.push(backstageMonitor);
var musicBoxMonitor = game.addChild(new SecurityMonitor('musicBox', 624, 600));
securityMonitors.push(musicBoxMonitor);
var kidsCoveMonitor = game.addChild(new SecurityMonitor('kidsCove', 924, 600));
securityMonitors.push(kidsCoveMonitor);
var gameAreaMonitor = game.addChild(new SecurityMonitor('gameArea', 1224, 600));
securityMonitors.push(gameAreaMonitor);
// Main security system
var securitySystem = game.addChild(new SecuritySystem());
securitySystem.x = 1024;
securitySystem.y = 600;
securitySystem.alpha = 0;
// Security mode state
var isSecurityMode = false;
// Enhanced animatronics with shadows and glow effects
var bunny = game.addChild(new Bunny());
bunny.x = 1024;
bunny.y = 1500;
// Bunny shadow
var bunnyShadow = game.addChild(LK.getAsset('bunny', {
anchorX: 0.5,
anchorY: 1.0,
x: 1030,
y: 1510,
alpha: 0.4,
scaleX: 0.9,
scaleY: 0.3
}));
bunnyShadow.tint = 0x000000;
var freddy = game.addChild(new Freddy());
freddy.x = 900;
freddy.y = 1500;
// Freddy glow effect for intimidation
var freddyGlow = game.addChild(LK.getAsset('freddy', {
anchorX: 0.5,
anchorY: 1.0,
x: 900,
y: 1500,
alpha: 0,
scaleX: 1.2,
scaleY: 1.2
}));
freddyGlow.tint = 0x4b0082;
var chica = game.addChild(new Chica());
chica.x = 1150;
chica.y = 1500;
// Chica glint effect
var chicaGlint = game.addChild(LK.getAsset('chica', {
anchorX: 0.5,
anchorY: 1.0,
x: 1150,
y: 1500,
alpha: 0,
scaleX: 1.1,
scaleY: 1.1
}));
chicaGlint.tint = 0xffffff;
var foxy = game.addChild(new Foxy());
foxy.x = 800;
foxy.y = 1500;
// Foxy menacing aura
var foxyAura = game.addChild(LK.getAsset('bunny', {
anchorX: 0.5,
anchorY: 1.0,
x: 800,
y: 1500,
alpha: 0,
scaleX: 1.3,
scaleY: 1.3
}));
foxyAura.tint = 0x8b0000;
var bonnie = game.addChild(new Bonnie());
bonnie.x = 850;
bonnie.y = 1500;
var goldenFreddy = game.addChild(new GoldenFreddy());
goldenFreddy.x = 1024;
goldenFreddy.y = 1500;
// Golden Freddy supernatural glow
var goldenGlow = game.addChild(LK.getAsset('freddy', {
anchorX: 0.5,
anchorY: 1.0,
x: 1024,
y: 1500,
alpha: 0,
scaleX: 1.4,
scaleY: 1.4
}));
goldenGlow.tint = 0xffd700;
var puppet = game.addChild(new Puppet());
puppet.x = 600;
puppet.y = 1500;
// Puppet eerie glow
var puppetGlow = game.addChild(LK.getAsset('bunny', {
anchorX: 0.5,
anchorY: 1.0,
x: 600,
y: 1500,
alpha: 0,
scaleX: 1.2,
scaleY: 1.2
}));
puppetGlow.tint = 0x4a4a4a;
var mangle = game.addChild(new Mangle());
mangle.x = 1200;
mangle.y = 1500;
var balloonBoy = game.addChild(new BalloonBoy());
balloonBoy.x = 750;
balloonBoy.y = 1500;
// Mask with enhanced visuals
var mask = game.addChild(LK.getAsset('mask', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1400,
alpha: 0
}));
// Mask glow effect
var maskGlow = game.addChild(LK.getAsset('mask', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1400,
alpha: 0,
scaleX: 1.1,
scaleY: 1.1
}));
maskGlow.tint = 0xffd700;
// Mask shadow
var maskShadow = game.addChild(LK.getAsset('mask', {
anchorX: 0.5,
anchorY: 0.5,
x: 1030,
y: 1410,
alpha: 0,
scaleX: 0.95,
scaleY: 0.95
}));
maskShadow.tint = 0x000000;
// Flashlight with enhanced beam effects
var flashlight = game.addChild(LK.getAsset('flashlight', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1600,
alpha: 0
}));
// Flashlight beam layers for realistic lighting
var flashlightBeam1 = game.addChild(LK.getAsset('flashlight', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1500,
alpha: 0,
scaleX: 2.0,
scaleY: 3.0
}));
flashlightBeam1.tint = 0xffffaa;
var flashlightBeam2 = game.addChild(LK.getAsset('flashlight', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1400,
alpha: 0,
scaleX: 1.5,
scaleY: 2.5
}));
flashlightBeam2.tint = 0xffffff;
// Subtle flashlight flicker effect
var flashlightFlicker = false;
var isFlashlightOn = false;
var isCameraMode = false;
// Enhanced battery display
var batteryBar = LK.gui.bottom.addChild(LK.getAsset('battery', {
anchorX: 0.5,
anchorY: 1.0,
y: -50
}));
// Battery background frame
var batteryFrame = LK.gui.bottom.addChild(LK.getAsset('battery', {
anchorX: 0.5,
anchorY: 1.0,
y: -50,
scaleY: 1.2,
alpha: 0.3
}));
batteryFrame.tint = 0x333333;
// Battery warning overlay
var batteryWarning = LK.gui.bottom.addChild(LK.getAsset('battery', {
anchorX: 0.5,
anchorY: 1.0,
y: -50,
alpha: 0
}));
batteryWarning.tint = 0xff3333;
// Battery charge indicator particles
var batteryParticles = [];
for (var p = 0; p < 5; p++) {
var particle = LK.gui.bottom.addChild(LK.getAsset('battery', {
anchorX: 0.5,
anchorY: 0.5,
x: -120 + p * 60,
y: -70,
scaleX: 0.1,
scaleY: 0.1,
alpha: 0
}));
particle.tint = 0x00ff00;
batteryParticles.push(particle);
}
function updateTime() {
var hours = Math.floor(nightTimer / 4800) + 12; // Each hour is 4800 frames
var minutes = Math.floor(nightTimer % 4800 / 80); // Each minute is 80 frames
if (hours > 12) hours -= 12;
if (hours === 0) hours = 12;
var ampm = nightTimer < 21600 ? 'AM' : 'AM'; // All night hours are AM
var timeString = hours + ':' + (minutes < 10 ? '0' : '') + minutes + ' ' + ampm;
timeText.setText(timeString);
}
function updateBattery() {
batteryLevel -= batteryDrain / 60; // Drain per frame
if (batteryLevel < 0) batteryLevel = 0;
batteryText.setText('Battery: ' + Math.floor(batteryLevel) + '%');
// Update battery bar color with smooth transitions
if (batteryLevel > 50) {
batteryBar.tint = 0x00ff00;
batteryWarning.alpha = 0;
} else if (batteryLevel > 25) {
batteryBar.tint = 0xffffff;
batteryWarning.alpha = 0;
} else {
batteryBar.tint = 0xff0000;
// Critical battery warning effect
if (batteryLevel < 25) {
batteryWarning.alpha = 0.3 + Math.sin(LK.ticks * 0.3) * 0.2;
}
}
// Scale battery bar with smooth animation
tween.to(batteryBar, {
scaleX: batteryLevel / 100
}, 100);
// Update battery particle effects
for (var i = 0; i < batteryParticles.length; i++) {
var particle = batteryParticles[i];
if (i < Math.floor(batteryLevel / 20)) {
particle.alpha = 0.8;
if (batteryLevel > 80) particle.tint = 0x00ff00;else if (batteryLevel > 40) particle.tint = 0xffff00;else particle.tint = 0xff0000;
// Subtle pulse animation
particle.scaleX = 0.1 + Math.sin(LK.ticks * 0.2 + i) * 0.02;
particle.scaleY = 0.1 + Math.sin(LK.ticks * 0.2 + i) * 0.02;
} else {
particle.alpha = 0.2;
}
}
// Reset battery drain
batteryDrain = 0.5;
}
function triggerJumpscare() {
if (!isGameActive) return;
isGameActive = false;
LK.getSound('jumpscare').play();
LK.effects.flashScreen(0xff0000, 2000);
LK.setTimeout(function () {
LK.showGameOver();
}, 2000);
}
function completeNight() {
currentNight++;
if (currentNight > 5) {
LK.showYouWin();
return;
}
// Reset for next night
nightTimer = 0;
batteryLevel = 100;
nightText.setText('Night ' + currentNight);
// Reset bunny
bunny.currentRoom = 'hall';
bunny.isAtDoor = false;
bunny.moveDelay = Math.max(120, 300 - currentNight * 30); // Faster each night
// Reset freddy
freddy.currentRoom = 'stage';
freddy.isAtDoor = false;
freddy.moveDelay = Math.max(150, 400 - currentNight * 40); // Faster each night
// Reset chica
chica.currentRoom = 'kitchen';
chica.isAtDoor = false;
chica.moveDelay = Math.max(130, 350 - currentNight * 35); // Faster each night
// Reset foxy
foxy.currentRoom = 'pirateCove';
foxy.isRunning = false;
foxy.aggressionLevel = 0;
foxy.moveDelay = Math.max(100, 250 - currentNight * 25); // Much faster each night
// Reset bonnie
bonnie.currentRoom = 'stage';
bonnie.isAtDoor = false;
bonnie.isHiding = false;
bonnie.moveDelay = Math.max(140, 320 - currentNight * 30); // Faster each night
// Reset Golden Freddy
goldenFreddy.isActive = false;
goldenFreddy.currentRoom = 'backstage';
goldenFreddy.teleportChance = 0.001;
// Reset Puppet
puppet.musicBoxLevel = 100;
puppet.isEscaping = false;
puppet.currentRoom = 'musicBox';
// Reset Mangle
mangle.isOnCeiling = false;
mangle.staticNoise = false;
mangle.currentRoom = 'kidsCove';
mangle.moveDelay = Math.max(120, 280 - currentNight * 25);
// Reset Balloon Boy
balloonBoy.isInVent = false;
balloonBoy.hasDisabledFlashlight = false;
balloonBoy.currentRoom = 'gameArea';
balloonBoy.moveDelay = Math.max(150, 300 - currentNight * 30);
// Reset mask
hasMask = false;
mask.alpha = 0;
maskCooldown = 0;
// Reset doors
leftDoor.isOpen = true;
rightDoor.isOpen = true;
leftDoor.getChildAt(0).alpha = 0.5;
rightDoor.getChildAt(0).alpha = 0.5;
// Reset door button colors
leftDoorButton.tint = 0x00ff00;
rightDoorButton.tint = 0x00ff00;
// Reset security system
isSecurityMode = false;
if (securitySystem) {
securitySystem.lockdownMode = false;
securitySystem.getChildAt(2).tint = 0xffffff; // Reset lockdown button
}
}
// Event handlers
game.down = function (x, y, obj) {
// Check door button clicks first
if (x < 200 && y > 1400 && y < 1800 && !isCameraMode) {
// Left door button clicked
leftDoor.toggle();
return;
}
if (x > 1848 && y > 1400 && y < 1800 && !isCameraMode) {
// Right door button clicked
rightDoor.toggle();
return;
}
// Toggle camera mode
if (y > 1200) {
isCameraMode = !isCameraMode;
if (isCameraMode) {
cameraPanel.alpha = 0.8;
batteryDrain += 1;
} else {
cameraPanel.alpha = 0;
if (currentCamera) {
currentCamera.isActive = false;
currentCamera.getChildAt(0).tint = 0xffffff;
currentCamera = null;
}
}
}
// Toggle mask (middle area tap)
if (y >= 1000 && y < 1600 && !isCameraMode && maskCooldown <= 0) {
hasMask = !hasMask;
if (hasMask && batteryLevel > 0) {
mask.alpha = 0.8;
batteryDrain += 1.5;
maskCooldown = 60; // 1 second cooldown
} else {
mask.alpha = 0;
}
LK.getSound('mask').play();
}
// Toggle security system (top area tap)
if (y < 800 && !isCameraMode) {
isSecurityMode = !isSecurityMode;
if (isSecurityMode && batteryLevel > 0) {
batteryDrain += 1;
}
LK.getSound('security').play();
}
// Toggle flashlight
if (y < 1200 && !isCameraMode && !isSecurityMode) {
isFlashlightOn = !isFlashlightOn;
if (isFlashlightOn && batteryLevel > 0) {
flashlight.alpha = 0.6;
flashlightBeam1.alpha = 0.3;
flashlightBeam2.alpha = 0.5;
batteryDrain += 2;
} else {
flashlight.alpha = 0;
flashlightBeam1.alpha = 0;
flashlightBeam2.alpha = 0;
}
}
};
game.update = function () {
if (!isGameActive) return;
nightTimer++;
updateTime();
updateBattery();
// Check if night is complete
if (nightTimer >= nightDuration) {
completeNight();
return;
}
// Update mask cooldown
if (maskCooldown > 0) {
maskCooldown--;
}
// Update door button colors based on door state
if (leftDoor.isOpen) {
leftDoorButton.tint = 0x00ff00; // Green when open
} else {
leftDoorButton.tint = 0xff0000; // Red when closed
}
if (rightDoor.isOpen) {
rightDoorButton.tint = 0x00ff00; // Green when open
} else {
rightDoorButton.tint = 0xff0000; // Red when closed
}
// Turn off mask and flashlight if battery is dead
if (batteryLevel <= 0) {
flashlight.alpha = 0;
flashlightBeam1.alpha = 0;
flashlightBeam2.alpha = 0;
isFlashlightOn = false;
mask.alpha = 0;
maskGlow.alpha = 0;
maskShadow.alpha = 0;
hasMask = false;
// Force doors closed if battery is dead
if (leftDoor.isOpen) {
leftDoor.isOpen = false;
leftDoor.getChildAt(0).alpha = 1.0;
}
if (rightDoor.isOpen) {
rightDoor.isOpen = false;
rightDoor.getChildAt(0).alpha = 1.0;
}
}
// Update atmospheric effects based on game state
// Flashlight flicker effect
if (isFlashlightOn && batteryLevel < 30) {
flashlightFlicker = !flashlightFlicker;
if (flashlightFlicker && Math.random() < 0.1) {
flashlightBeam1.alpha *= 0.7;
flashlightBeam2.alpha *= 0.8;
}
}
// Dynamic mask effects
if (hasMask) {
maskGlow.alpha = 0.2;
maskShadow.alpha = 0.3;
// Breathing effect
var breathScale = 1.0 + Math.sin(LK.ticks * 0.1) * 0.02;
mask.scaleX = breathScale;
mask.scaleY = breathScale;
} else {
maskGlow.alpha = 0;
maskShadow.alpha = 0;
}
// Animatronic glow effects based on proximity
if (freddy.isAtDoor) {
freddyGlow.alpha = 0.4 + Math.sin(LK.ticks * 0.2) * 0.2;
} else {
freddyGlow.alpha = 0;
}
if (goldenFreddy.isActive) {
goldenGlow.alpha = 0.5 + Math.sin(LK.ticks * 0.15) * 0.3;
} else {
goldenGlow.alpha = 0;
}
if (puppet.isEscaping) {
puppetGlow.alpha = 0.6 + Math.sin(LK.ticks * 0.25) * 0.2;
} else {
puppetGlow.alpha = 0;
}
if (foxy.isRunning) {
foxyAura.alpha = 0.7;
tween.to(foxyAura, {
scaleX: 1.5,
scaleY: 1.5
}, 200);
} else {
foxyAura.alpha = 0;
foxyAura.scaleX = 1.3;
foxyAura.scaleY = 1.3;
}
// Chica glint when near
if (chica.isAtDoor && Math.random() < 0.05) {
chicaGlint.alpha = 1.0;
tween.to(chicaGlint, {
alpha: 0
}, 300);
}
// Update security monitors
if (isSecurityMode) {
var animatronics = [bunny, freddy, chica, foxy, bonnie, goldenFreddy, puppet, mangle, balloonBoy];
for (var i = 0; i < securityMonitors.length; i++) {
securityMonitors[i].updateStatus(animatronics);
}
// Security system power drain
batteryDrain += 1.5;
// Show security elements
securityPanel.alpha = 0.8;
securitySystem.alpha = 1.0;
for (var j = 0; j < securityMonitors.length; j++) {
securityMonitors[j].alpha = 1.0;
}
} else {
// Hide security elements
securityPanel.alpha = 0;
securitySystem.alpha = 0;
for (var k = 0; k < securityMonitors.length; k++) {
securityMonitors[k].alpha = 0;
}
}
// Update camera visibility
if (isCameraMode && currentCamera) {
// Show animatronics if in same room as camera
if (bunny.currentRoom === currentCamera.roomName) {
bunny.alpha = 1.0;
} else {
bunny.alpha = 0.3;
}
if (freddy.currentRoom === currentCamera.roomName) {
freddy.alpha = 1.0;
} else {
freddy.alpha = 0.3;
}
if (chica.currentRoom === currentCamera.roomName) {
chica.alpha = 1.0;
} else {
chica.alpha = 0.3;
}
if (foxy.currentRoom === currentCamera.roomName && !foxy.isHiding) {
foxy.alpha = 1.0;
} else {
foxy.alpha = 0.3;
}
if (bonnie.currentRoom === currentCamera.roomName && !bonnie.isHiding) {
bonnie.alpha = 1.0;
} else {
bonnie.alpha = 0.3;
}
if (goldenFreddy.currentRoom === currentCamera.roomName && goldenFreddy.isActive) {
goldenFreddy.alpha = 1.0;
} else {
goldenFreddy.alpha = 0.3;
}
if (puppet.currentRoom === currentCamera.roomName) {
puppet.alpha = 1.0;
} else {
puppet.alpha = 0.3;
}
if (mangle.currentRoom === currentCamera.roomName) {
mangle.alpha = 1.0;
} else {
mangle.alpha = 0.3;
}
if (balloonBoy.currentRoom === currentCamera.roomName) {
balloonBoy.alpha = 1.0;
} else {
balloonBoy.alpha = 0.3;
}
} else if (!isSecurityMode) {
bunny.alpha = 0;
freddy.alpha = 0;
chica.alpha = 0;
foxy.alpha = 0;
bonnie.alpha = 0;
goldenFreddy.alpha = 0;
puppet.alpha = 0;
mangle.alpha = 0;
balloonBoy.alpha = 0;
}
};
// Start ambient music
LK.playMusic('ambient'); ===================================================================
--- original.js
+++ change.js
@@ -726,22 +726,64 @@
fill: 0x00FF00
});
batteryText.anchor.set(1, 0);
LK.gui.topRight.addChild(batteryText);
-// Office setup
+// Office setup with enhanced visuals
var office = game.addChild(LK.getAsset('office', {
anchorX: 0.5,
anchorY: 1.0,
x: 1024,
y: 2732
}));
-// Doors
+// Add ambient lighting overlay
+var ambientLight = game.addChild(LK.getAsset('room', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1366,
+ scaleX: 5.0,
+ scaleY: 5.0,
+ alpha: 0.15
+}));
+ambientLight.tint = 0x4a4a2a; // Warm dim lighting
+// Add depth shadows
+var officeShadow = game.addChild(LK.getAsset('office', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 1030,
+ y: 2738,
+ alpha: 0.3
+}));
+officeShadow.tint = 0x000000;
+// Subtle pulsing ambient effect
+tween.to(ambientLight, {
+ alpha: 0.25
+}, 3000).yoyo(true).repeat(-1);
+// Doors with enhanced graphics
var leftDoor = game.addChild(new Door('left'));
leftDoor.x = 200;
leftDoor.y = 1800;
+// Left door shadow
+var leftDoorShadow = game.addChild(LK.getAsset('door', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 206,
+ y: 1806,
+ alpha: 0.4
+}));
+leftDoorShadow.tint = 0x000000;
var rightDoor = game.addChild(new Door('right'));
rightDoor.x = 1848;
rightDoor.y = 1800;
+// Right door shadow
+var rightDoorShadow = game.addChild(LK.getAsset('door', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 1854,
+ y: 1806,
+ alpha: 0.4
+}));
+rightDoorShadow.tint = 0x000000;
// Door control buttons
var leftDoorButton = game.addChild(LK.getAsset('door', {
anchorX: 0.5,
anchorY: 0.5,
@@ -832,68 +874,203 @@
securitySystem.y = 600;
securitySystem.alpha = 0;
// Security mode state
var isSecurityMode = false;
-// Bunny
+// Enhanced animatronics with shadows and glow effects
var bunny = game.addChild(new Bunny());
bunny.x = 1024;
bunny.y = 1500;
-// Freddy
+// Bunny shadow
+var bunnyShadow = game.addChild(LK.getAsset('bunny', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 1030,
+ y: 1510,
+ alpha: 0.4,
+ scaleX: 0.9,
+ scaleY: 0.3
+}));
+bunnyShadow.tint = 0x000000;
var freddy = game.addChild(new Freddy());
freddy.x = 900;
freddy.y = 1500;
-// Chica
+// Freddy glow effect for intimidation
+var freddyGlow = game.addChild(LK.getAsset('freddy', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 900,
+ y: 1500,
+ alpha: 0,
+ scaleX: 1.2,
+ scaleY: 1.2
+}));
+freddyGlow.tint = 0x4b0082;
var chica = game.addChild(new Chica());
chica.x = 1150;
chica.y = 1500;
-// Foxy
+// Chica glint effect
+var chicaGlint = game.addChild(LK.getAsset('chica', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 1150,
+ y: 1500,
+ alpha: 0,
+ scaleX: 1.1,
+ scaleY: 1.1
+}));
+chicaGlint.tint = 0xffffff;
var foxy = game.addChild(new Foxy());
foxy.x = 800;
foxy.y = 1500;
-// Bonnie
+// Foxy menacing aura
+var foxyAura = game.addChild(LK.getAsset('bunny', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 800,
+ y: 1500,
+ alpha: 0,
+ scaleX: 1.3,
+ scaleY: 1.3
+}));
+foxyAura.tint = 0x8b0000;
var bonnie = game.addChild(new Bonnie());
bonnie.x = 850;
bonnie.y = 1500;
-// Golden Freddy
var goldenFreddy = game.addChild(new GoldenFreddy());
goldenFreddy.x = 1024;
goldenFreddy.y = 1500;
-// Puppet
+// Golden Freddy supernatural glow
+var goldenGlow = game.addChild(LK.getAsset('freddy', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 1024,
+ y: 1500,
+ alpha: 0,
+ scaleX: 1.4,
+ scaleY: 1.4
+}));
+goldenGlow.tint = 0xffd700;
var puppet = game.addChild(new Puppet());
puppet.x = 600;
puppet.y = 1500;
-// Mangle
+// Puppet eerie glow
+var puppetGlow = game.addChild(LK.getAsset('bunny', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 600,
+ y: 1500,
+ alpha: 0,
+ scaleX: 1.2,
+ scaleY: 1.2
+}));
+puppetGlow.tint = 0x4a4a4a;
var mangle = game.addChild(new Mangle());
mangle.x = 1200;
mangle.y = 1500;
-// Balloon Boy
var balloonBoy = game.addChild(new BalloonBoy());
balloonBoy.x = 750;
balloonBoy.y = 1500;
-// Mask
+// Mask with enhanced visuals
var mask = game.addChild(LK.getAsset('mask', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1400,
alpha: 0
}));
-// Flashlight
+// Mask glow effect
+var maskGlow = game.addChild(LK.getAsset('mask', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1400,
+ alpha: 0,
+ scaleX: 1.1,
+ scaleY: 1.1
+}));
+maskGlow.tint = 0xffd700;
+// Mask shadow
+var maskShadow = game.addChild(LK.getAsset('mask', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1030,
+ y: 1410,
+ alpha: 0,
+ scaleX: 0.95,
+ scaleY: 0.95
+}));
+maskShadow.tint = 0x000000;
+// Flashlight with enhanced beam effects
var flashlight = game.addChild(LK.getAsset('flashlight', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1600,
alpha: 0
}));
+// Flashlight beam layers for realistic lighting
+var flashlightBeam1 = game.addChild(LK.getAsset('flashlight', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1500,
+ alpha: 0,
+ scaleX: 2.0,
+ scaleY: 3.0
+}));
+flashlightBeam1.tint = 0xffffaa;
+var flashlightBeam2 = game.addChild(LK.getAsset('flashlight', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1400,
+ alpha: 0,
+ scaleX: 1.5,
+ scaleY: 2.5
+}));
+flashlightBeam2.tint = 0xffffff;
+// Subtle flashlight flicker effect
+var flashlightFlicker = false;
var isFlashlightOn = false;
var isCameraMode = false;
-// Battery bar
+// Enhanced battery display
var batteryBar = LK.gui.bottom.addChild(LK.getAsset('battery', {
anchorX: 0.5,
anchorY: 1.0,
y: -50
}));
+// Battery background frame
+var batteryFrame = LK.gui.bottom.addChild(LK.getAsset('battery', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ y: -50,
+ scaleY: 1.2,
+ alpha: 0.3
+}));
+batteryFrame.tint = 0x333333;
+// Battery warning overlay
+var batteryWarning = LK.gui.bottom.addChild(LK.getAsset('battery', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ y: -50,
+ alpha: 0
+}));
+batteryWarning.tint = 0xff3333;
+// Battery charge indicator particles
+var batteryParticles = [];
+for (var p = 0; p < 5; p++) {
+ var particle = LK.gui.bottom.addChild(LK.getAsset('battery', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: -120 + p * 60,
+ y: -70,
+ scaleX: 0.1,
+ scaleY: 0.1,
+ alpha: 0
+ }));
+ particle.tint = 0x00ff00;
+ batteryParticles.push(particle);
+}
function updateTime() {
var hours = Math.floor(nightTimer / 4800) + 12; // Each hour is 4800 frames
var minutes = Math.floor(nightTimer % 4800 / 80); // Each minute is 80 frames
if (hours > 12) hours -= 12;
@@ -905,18 +1082,39 @@
function updateBattery() {
batteryLevel -= batteryDrain / 60; // Drain per frame
if (batteryLevel < 0) batteryLevel = 0;
batteryText.setText('Battery: ' + Math.floor(batteryLevel) + '%');
- // Update battery bar color
+ // Update battery bar color with smooth transitions
if (batteryLevel > 50) {
batteryBar.tint = 0x00ff00;
+ batteryWarning.alpha = 0;
} else if (batteryLevel > 25) {
batteryBar.tint = 0xffffff;
+ batteryWarning.alpha = 0;
} else {
batteryBar.tint = 0xff0000;
+ // Critical battery warning effect
+ if (batteryLevel < 25) {
+ batteryWarning.alpha = 0.3 + Math.sin(LK.ticks * 0.3) * 0.2;
+ }
}
- // Scale battery bar
- batteryBar.scaleX = batteryLevel / 100;
+ // Scale battery bar with smooth animation
+ tween.to(batteryBar, {
+ scaleX: batteryLevel / 100
+ }, 100);
+ // Update battery particle effects
+ for (var i = 0; i < batteryParticles.length; i++) {
+ var particle = batteryParticles[i];
+ if (i < Math.floor(batteryLevel / 20)) {
+ particle.alpha = 0.8;
+ if (batteryLevel > 80) particle.tint = 0x00ff00;else if (batteryLevel > 40) particle.tint = 0xffff00;else particle.tint = 0xff0000;
+ // Subtle pulse animation
+ particle.scaleX = 0.1 + Math.sin(LK.ticks * 0.2 + i) * 0.02;
+ particle.scaleY = 0.1 + Math.sin(LK.ticks * 0.2 + i) * 0.02;
+ } else {
+ particle.alpha = 0.2;
+ }
+ }
// Reset battery drain
batteryDrain = 0.5;
}
function triggerJumpscare() {
@@ -1049,11 +1247,15 @@
if (y < 1200 && !isCameraMode && !isSecurityMode) {
isFlashlightOn = !isFlashlightOn;
if (isFlashlightOn && batteryLevel > 0) {
flashlight.alpha = 0.6;
+ flashlightBeam1.alpha = 0.3;
+ flashlightBeam2.alpha = 0.5;
batteryDrain += 2;
} else {
flashlight.alpha = 0;
+ flashlightBeam1.alpha = 0;
+ flashlightBeam2.alpha = 0;
}
}
};
game.update = function () {
@@ -1083,10 +1285,14 @@
}
// Turn off mask and flashlight if battery is dead
if (batteryLevel <= 0) {
flashlight.alpha = 0;
+ flashlightBeam1.alpha = 0;
+ flashlightBeam2.alpha = 0;
isFlashlightOn = false;
mask.alpha = 0;
+ maskGlow.alpha = 0;
+ maskShadow.alpha = 0;
hasMask = false;
// Force doors closed if battery is dead
if (leftDoor.isOpen) {
leftDoor.isOpen = false;
@@ -1096,8 +1302,63 @@
rightDoor.isOpen = false;
rightDoor.getChildAt(0).alpha = 1.0;
}
}
+ // Update atmospheric effects based on game state
+ // Flashlight flicker effect
+ if (isFlashlightOn && batteryLevel < 30) {
+ flashlightFlicker = !flashlightFlicker;
+ if (flashlightFlicker && Math.random() < 0.1) {
+ flashlightBeam1.alpha *= 0.7;
+ flashlightBeam2.alpha *= 0.8;
+ }
+ }
+ // Dynamic mask effects
+ if (hasMask) {
+ maskGlow.alpha = 0.2;
+ maskShadow.alpha = 0.3;
+ // Breathing effect
+ var breathScale = 1.0 + Math.sin(LK.ticks * 0.1) * 0.02;
+ mask.scaleX = breathScale;
+ mask.scaleY = breathScale;
+ } else {
+ maskGlow.alpha = 0;
+ maskShadow.alpha = 0;
+ }
+ // Animatronic glow effects based on proximity
+ if (freddy.isAtDoor) {
+ freddyGlow.alpha = 0.4 + Math.sin(LK.ticks * 0.2) * 0.2;
+ } else {
+ freddyGlow.alpha = 0;
+ }
+ if (goldenFreddy.isActive) {
+ goldenGlow.alpha = 0.5 + Math.sin(LK.ticks * 0.15) * 0.3;
+ } else {
+ goldenGlow.alpha = 0;
+ }
+ if (puppet.isEscaping) {
+ puppetGlow.alpha = 0.6 + Math.sin(LK.ticks * 0.25) * 0.2;
+ } else {
+ puppetGlow.alpha = 0;
+ }
+ if (foxy.isRunning) {
+ foxyAura.alpha = 0.7;
+ tween.to(foxyAura, {
+ scaleX: 1.5,
+ scaleY: 1.5
+ }, 200);
+ } else {
+ foxyAura.alpha = 0;
+ foxyAura.scaleX = 1.3;
+ foxyAura.scaleY = 1.3;
+ }
+ // Chica glint when near
+ if (chica.isAtDoor && Math.random() < 0.05) {
+ chicaGlint.alpha = 1.0;
+ tween.to(chicaGlint, {
+ alpha: 0
+ }, 300);
+ }
// Update security monitors
if (isSecurityMode) {
var animatronics = [bunny, freddy, chica, foxy, bonnie, goldenFreddy, puppet, mangle, balloonBoy];
for (var i = 0; i < securityMonitors.length; i++) {