/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// BellyBulge represents the lion's struggle inside the peacock
var BellyBulge = Container.expand(function () {
var self = Container.call(this);
var bulgeGraphics = self.attachAsset('belly_bulge', {
anchorX: 0.5,
anchorY: 0.5
});
self.intensity = 0; // How violent the struggle is (0-1)
self.isActive = false;
// Show bulge with animation
self.showBulge = function (intensity) {
self.intensity = intensity;
self.isActive = true;
self.alpha = 1;
// Scale based on intensity
var targetScale = 0.5 + intensity * 1.5;
tween(self, {
scaleX: targetScale,
scaleY: targetScale
}, {
duration: 200,
easing: tween.easeOut
});
// Slight position shake
var shakeAmount = intensity * 20;
tween(self, {
x: self.x + (Math.random() - 0.5) * shakeAmount,
y: self.y + (Math.random() - 0.5) * shakeAmount
}, {
duration: 100,
easing: tween.easeInOut
});
};
// Hide bulge
self.hideBulge = function () {
self.isActive = false;
tween(self, {
alpha: 0,
scaleX: 0.1,
scaleY: 0.1
}, {
duration: 300,
easing: tween.easeIn
});
};
return self;
});
// Peacock class - the sleeping bird with internal royal prisoner
var Peacock = Container.expand(function () {
var self = Container.call(this);
// Create peacock parts
self.tail = self.attachAsset('peacock_tail', {
anchorX: 0.5,
anchorY: 0.5,
x: -150,
y: 0
});
self.body = self.attachAsset('peacock_body', {
anchorX: 0.5,
anchorY: 0.5
});
self.head = self.attachAsset('peacock_head', {
anchorX: 0.5,
anchorY: 0.5,
x: 180,
y: -50
});
// Eyes start closed
self.leftEye = self.attachAsset('eye_closed', {
anchorX: 0.5,
anchorY: 0.5,
x: 170,
y: -60
});
self.rightEye = self.attachAsset('eye_closed', {
anchorX: 0.5,
anchorY: 0.5,
x: 190,
y: -60
});
// Sleep state
self.sleepLevel = 1.0; // 1.0 = deep sleep, 0.0 = awake
self.disturbanceLevel = 0; // How disturbed the peacock is
self.isAwake = false;
// Belly bulges for lion struggles
self.bellyBulges = [];
for (var i = 0; i < 3; i++) {
var bulge = new BellyBulge();
bulge.x = (Math.random() - 0.5) * 200;
bulge.y = (Math.random() - 0.5) * 100;
bulge.alpha = 0;
self.bellyBulges.push(bulge);
self.addChild(bulge);
}
// Wake up the peacock
self.wakeUp = function () {
if (self.isAwake) return;
self.isAwake = true;
// Change eyes to open
self.leftEye.destroy();
self.rightEye.destroy();
self.leftEye = self.attachAsset('eye_open', {
anchorX: 0.5,
anchorY: 0.5,
x: 170,
y: -60
});
self.rightEye = self.attachAsset('eye_open', {
anchorX: 0.5,
anchorY: 0.5,
x: 190,
y: -60
});
// Animate awakening
tween(self, {
scaleY: 1.2
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(self, {
scaleY: 1.0
}, {
duration: 300
});
}
});
};
// Create belly bulge at random position
self.createBellyBulge = function (intensity) {
// Find inactive bulge
for (var i = 0; i < self.bellyBulges.length; i++) {
var bulge = self.bellyBulges[i];
if (!bulge.isActive) {
// Position randomly on belly
bulge.x = (Math.random() - 0.5) * 200;
bulge.y = (Math.random() - 0.5) * 100;
bulge.showBulge(intensity);
// Hide after duration
LK.setTimeout(function () {
bulge.hideBulge();
}, 500 + Math.random() * 1000);
break;
}
}
};
return self;
});
/****
* Initialize Game
****/
// Game variables
var game = new LK.Game({
backgroundColor: 0x2C1810 // Dark bedroom background
});
/****
* Game Code
****/
// Game variables
// Peacock body - large elegant bird
// Peacock head - smaller circle
// Peacock tail feathers - decorative fan
// Luxurious bed
// Bed sheets
// Lion belly bulge - shows internal struggle
// Peacock eye closed
// Peacock eye open
// Sound effects
// Tween library for smooth animations
var gameTime = 0;
var lionStruggleIntensity = 0.1; // Starts low, increases over time
var maxDisturbance = 100; // Peacock wakes up at this level
var isDragging = false;
var dragStartX, dragStartY;
var peacockBaseX, peacockBaseY;
// Create the luxurious bed
var bed = game.addChild(LK.getAsset('bed', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
}));
var bedSheets = game.addChild(LK.getAsset('bed_sheets', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
}));
// Create the peacock
var peacock = game.addChild(new Peacock());
peacock.x = 1024;
peacock.y = 1300;
peacockBaseX = peacock.x;
peacockBaseY = peacock.y;
// UI Elements
var scoreText = new Text2('Sleep Time: 0s', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var instructionText = new Text2('Drag peacock gently to keep it asleep', {
size: 40,
fill: 0xCCCCCC
});
instructionText.anchor.set(0.5, 0);
instructionText.y = 80;
LK.gui.top.addChild(instructionText);
var disturbanceBar = new Text2('Calm', {
size: 50,
fill: 0x00FF00
});
disturbanceBar.anchor.set(0.5, 1);
LK.gui.bottom.addChild(disturbanceBar);
// Game mechanics
function updateLionStruggle() {
// Lion struggles more over time
lionStruggleIntensity = Math.min(1.0, 0.1 + gameTime / 30000); // Increases over 30 seconds
// Random lion struggle events
if (Math.random() < lionStruggleIntensity * 0.02) {
peacock.createBellyBulge(lionStruggleIntensity);
LK.getSound('rumble').play();
// Add disturbance if peacock isn't being moved gently
var movement = Math.abs(peacock.x - peacockBaseX) + Math.abs(peacock.y - peacockBaseY);
if (movement > 50) {
peacock.disturbanceLevel += lionStruggleIntensity * 10;
}
}
}
function updatePeacockSleep() {
// Gradually reduce disturbance if peacock is calm
if (peacock.disturbanceLevel > 0) {
var movement = Math.abs(peacock.x - peacockBaseX) + Math.abs(peacock.y - peacockBaseY);
if (movement < 20) {
peacock.disturbanceLevel -= 0.5; // Calm down slowly
}
}
peacock.disturbanceLevel = Math.max(0, peacock.disturbanceLevel);
// Update disturbance indicator
var disturbancePercent = peacock.disturbanceLevel / maxDisturbance;
var newText, newColor;
if (disturbancePercent < 0.3) {
newText = 'Calm';
newColor = 0x00FF00;
} else if (disturbancePercent < 0.7) {
newText = 'Restless';
newColor = 0xFFFF00;
} else {
newText = 'Disturbed!';
newColor = 0xFF0000;
}
// Recreate text with new color if text or color changed
if (disturbanceBar.text !== newText || disturbanceBar._style.fill !== newColor) {
LK.gui.bottom.removeChild(disturbanceBar);
disturbanceBar = new Text2(newText, {
size: 50,
fill: newColor
});
disturbanceBar.anchor.set(0.5, 1);
LK.gui.bottom.addChild(disturbanceBar);
}
// Check if peacock wakes up
if (peacock.disturbanceLevel >= maxDisturbance && !peacock.isAwake) {
peacock.wakeUp();
LK.showGameOver();
}
}
// Touch/mouse controls
game.down = function (x, y, obj) {
isDragging = true;
dragStartX = x;
dragStartY = y;
peacockBaseX = peacock.x;
peacockBaseY = peacock.y;
};
game.move = function (x, y, obj) {
if (isDragging && !peacock.isAwake) {
var deltaX = x - dragStartX;
var deltaY = y - dragStartY;
// Gentle movement multiplier
var sensitivity = 0.8;
peacock.x = peacockBaseX + deltaX * sensitivity;
peacock.y = peacockBaseY + deltaY * sensitivity;
// Keep peacock on the bed
peacock.x = Math.max(624, Math.min(1424, peacock.x));
peacock.y = Math.max(1166, Math.min(1566, peacock.y));
// Add slight disturbance for rapid movements
var movementSpeed = Math.abs(deltaX) + Math.abs(deltaY);
if (movementSpeed > 100) {
peacock.disturbanceLevel += 0.5;
}
}
};
game.up = function (x, y, obj) {
isDragging = false;
};
// Main game loop
game.update = function () {
if (peacock.isAwake) return;
gameTime += 16.67; // Approximately 60 FPS
// Update score
var sleepSeconds = Math.floor(gameTime / 1000);
scoreText.setText('Sleep Time: ' + sleepSeconds + 's');
LK.setScore(sleepSeconds);
// Update game mechanics
updateLionStruggle();
updatePeacockSleep();
// Gentle breathing animation for sleeping peacock
if (LK.ticks % 180 == 0) {
// Every 3 seconds
LK.getSound('sleep_breath').play();
tween(peacock, {
scaleY: 1.05
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(peacock, {
scaleY: 1.0
}, {
duration: 1000,
easing: tween.easeInOut
});
}
});
}
// Win condition - survive for 2 minutes
if (sleepSeconds >= 120) {
LK.showYouWin();
}
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// BellyBulge represents the lion's struggle inside the peacock
var BellyBulge = Container.expand(function () {
var self = Container.call(this);
var bulgeGraphics = self.attachAsset('belly_bulge', {
anchorX: 0.5,
anchorY: 0.5
});
self.intensity = 0; // How violent the struggle is (0-1)
self.isActive = false;
// Show bulge with animation
self.showBulge = function (intensity) {
self.intensity = intensity;
self.isActive = true;
self.alpha = 1;
// Scale based on intensity
var targetScale = 0.5 + intensity * 1.5;
tween(self, {
scaleX: targetScale,
scaleY: targetScale
}, {
duration: 200,
easing: tween.easeOut
});
// Slight position shake
var shakeAmount = intensity * 20;
tween(self, {
x: self.x + (Math.random() - 0.5) * shakeAmount,
y: self.y + (Math.random() - 0.5) * shakeAmount
}, {
duration: 100,
easing: tween.easeInOut
});
};
// Hide bulge
self.hideBulge = function () {
self.isActive = false;
tween(self, {
alpha: 0,
scaleX: 0.1,
scaleY: 0.1
}, {
duration: 300,
easing: tween.easeIn
});
};
return self;
});
// Peacock class - the sleeping bird with internal royal prisoner
var Peacock = Container.expand(function () {
var self = Container.call(this);
// Create peacock parts
self.tail = self.attachAsset('peacock_tail', {
anchorX: 0.5,
anchorY: 0.5,
x: -150,
y: 0
});
self.body = self.attachAsset('peacock_body', {
anchorX: 0.5,
anchorY: 0.5
});
self.head = self.attachAsset('peacock_head', {
anchorX: 0.5,
anchorY: 0.5,
x: 180,
y: -50
});
// Eyes start closed
self.leftEye = self.attachAsset('eye_closed', {
anchorX: 0.5,
anchorY: 0.5,
x: 170,
y: -60
});
self.rightEye = self.attachAsset('eye_closed', {
anchorX: 0.5,
anchorY: 0.5,
x: 190,
y: -60
});
// Sleep state
self.sleepLevel = 1.0; // 1.0 = deep sleep, 0.0 = awake
self.disturbanceLevel = 0; // How disturbed the peacock is
self.isAwake = false;
// Belly bulges for lion struggles
self.bellyBulges = [];
for (var i = 0; i < 3; i++) {
var bulge = new BellyBulge();
bulge.x = (Math.random() - 0.5) * 200;
bulge.y = (Math.random() - 0.5) * 100;
bulge.alpha = 0;
self.bellyBulges.push(bulge);
self.addChild(bulge);
}
// Wake up the peacock
self.wakeUp = function () {
if (self.isAwake) return;
self.isAwake = true;
// Change eyes to open
self.leftEye.destroy();
self.rightEye.destroy();
self.leftEye = self.attachAsset('eye_open', {
anchorX: 0.5,
anchorY: 0.5,
x: 170,
y: -60
});
self.rightEye = self.attachAsset('eye_open', {
anchorX: 0.5,
anchorY: 0.5,
x: 190,
y: -60
});
// Animate awakening
tween(self, {
scaleY: 1.2
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(self, {
scaleY: 1.0
}, {
duration: 300
});
}
});
};
// Create belly bulge at random position
self.createBellyBulge = function (intensity) {
// Find inactive bulge
for (var i = 0; i < self.bellyBulges.length; i++) {
var bulge = self.bellyBulges[i];
if (!bulge.isActive) {
// Position randomly on belly
bulge.x = (Math.random() - 0.5) * 200;
bulge.y = (Math.random() - 0.5) * 100;
bulge.showBulge(intensity);
// Hide after duration
LK.setTimeout(function () {
bulge.hideBulge();
}, 500 + Math.random() * 1000);
break;
}
}
};
return self;
});
/****
* Initialize Game
****/
// Game variables
var game = new LK.Game({
backgroundColor: 0x2C1810 // Dark bedroom background
});
/****
* Game Code
****/
// Game variables
// Peacock body - large elegant bird
// Peacock head - smaller circle
// Peacock tail feathers - decorative fan
// Luxurious bed
// Bed sheets
// Lion belly bulge - shows internal struggle
// Peacock eye closed
// Peacock eye open
// Sound effects
// Tween library for smooth animations
var gameTime = 0;
var lionStruggleIntensity = 0.1; // Starts low, increases over time
var maxDisturbance = 100; // Peacock wakes up at this level
var isDragging = false;
var dragStartX, dragStartY;
var peacockBaseX, peacockBaseY;
// Create the luxurious bed
var bed = game.addChild(LK.getAsset('bed', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
}));
var bedSheets = game.addChild(LK.getAsset('bed_sheets', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
}));
// Create the peacock
var peacock = game.addChild(new Peacock());
peacock.x = 1024;
peacock.y = 1300;
peacockBaseX = peacock.x;
peacockBaseY = peacock.y;
// UI Elements
var scoreText = new Text2('Sleep Time: 0s', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var instructionText = new Text2('Drag peacock gently to keep it asleep', {
size: 40,
fill: 0xCCCCCC
});
instructionText.anchor.set(0.5, 0);
instructionText.y = 80;
LK.gui.top.addChild(instructionText);
var disturbanceBar = new Text2('Calm', {
size: 50,
fill: 0x00FF00
});
disturbanceBar.anchor.set(0.5, 1);
LK.gui.bottom.addChild(disturbanceBar);
// Game mechanics
function updateLionStruggle() {
// Lion struggles more over time
lionStruggleIntensity = Math.min(1.0, 0.1 + gameTime / 30000); // Increases over 30 seconds
// Random lion struggle events
if (Math.random() < lionStruggleIntensity * 0.02) {
peacock.createBellyBulge(lionStruggleIntensity);
LK.getSound('rumble').play();
// Add disturbance if peacock isn't being moved gently
var movement = Math.abs(peacock.x - peacockBaseX) + Math.abs(peacock.y - peacockBaseY);
if (movement > 50) {
peacock.disturbanceLevel += lionStruggleIntensity * 10;
}
}
}
function updatePeacockSleep() {
// Gradually reduce disturbance if peacock is calm
if (peacock.disturbanceLevel > 0) {
var movement = Math.abs(peacock.x - peacockBaseX) + Math.abs(peacock.y - peacockBaseY);
if (movement < 20) {
peacock.disturbanceLevel -= 0.5; // Calm down slowly
}
}
peacock.disturbanceLevel = Math.max(0, peacock.disturbanceLevel);
// Update disturbance indicator
var disturbancePercent = peacock.disturbanceLevel / maxDisturbance;
var newText, newColor;
if (disturbancePercent < 0.3) {
newText = 'Calm';
newColor = 0x00FF00;
} else if (disturbancePercent < 0.7) {
newText = 'Restless';
newColor = 0xFFFF00;
} else {
newText = 'Disturbed!';
newColor = 0xFF0000;
}
// Recreate text with new color if text or color changed
if (disturbanceBar.text !== newText || disturbanceBar._style.fill !== newColor) {
LK.gui.bottom.removeChild(disturbanceBar);
disturbanceBar = new Text2(newText, {
size: 50,
fill: newColor
});
disturbanceBar.anchor.set(0.5, 1);
LK.gui.bottom.addChild(disturbanceBar);
}
// Check if peacock wakes up
if (peacock.disturbanceLevel >= maxDisturbance && !peacock.isAwake) {
peacock.wakeUp();
LK.showGameOver();
}
}
// Touch/mouse controls
game.down = function (x, y, obj) {
isDragging = true;
dragStartX = x;
dragStartY = y;
peacockBaseX = peacock.x;
peacockBaseY = peacock.y;
};
game.move = function (x, y, obj) {
if (isDragging && !peacock.isAwake) {
var deltaX = x - dragStartX;
var deltaY = y - dragStartY;
// Gentle movement multiplier
var sensitivity = 0.8;
peacock.x = peacockBaseX + deltaX * sensitivity;
peacock.y = peacockBaseY + deltaY * sensitivity;
// Keep peacock on the bed
peacock.x = Math.max(624, Math.min(1424, peacock.x));
peacock.y = Math.max(1166, Math.min(1566, peacock.y));
// Add slight disturbance for rapid movements
var movementSpeed = Math.abs(deltaX) + Math.abs(deltaY);
if (movementSpeed > 100) {
peacock.disturbanceLevel += 0.5;
}
}
};
game.up = function (x, y, obj) {
isDragging = false;
};
// Main game loop
game.update = function () {
if (peacock.isAwake) return;
gameTime += 16.67; // Approximately 60 FPS
// Update score
var sleepSeconds = Math.floor(gameTime / 1000);
scoreText.setText('Sleep Time: ' + sleepSeconds + 's');
LK.setScore(sleepSeconds);
// Update game mechanics
updateLionStruggle();
updatePeacockSleep();
// Gentle breathing animation for sleeping peacock
if (LK.ticks % 180 == 0) {
// Every 3 seconds
LK.getSound('sleep_breath').play();
tween(peacock, {
scaleY: 1.05
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(peacock, {
scaleY: 1.0
}, {
duration: 1000,
easing: tween.easeInOut
});
}
});
}
// Win condition - survive for 2 minutes
if (sleepSeconds >= 120) {
LK.showYouWin();
}
};