/**** * Classes ****/ var Bubble = Container.expand(function () { var self = Container.call(this); self.graphics = self.attachAsset('bubble', { anchorX: 0.5, anchorY: 0.5 }); self.popped = false; self.down = function (x, y, obj) { if (currentPhase === 'bath' && !self.popped) { self.popped = true; self.graphics.alpha = 0; LK.getSound('bubble').play(); bubblesPopped++; checkPhaseComplete(); } }; self.update = function () { if (!self.popped) { self.graphics.alpha = 0.7 + 0.3 * Math.sin(LK.ticks * 0.1 + self.x * 0.01); } }; return self; }); var Girl = Container.expand(function (type) { var self = Container.call(this); self.type = type; self.state = 'sleeping'; self.milkCount = 0; self.porridgeCount = 0; self.isCrying = false; self.diaperChanged = false; self.bathroomDone = false; self.bathDone = false; self.comfortTime = 0; var color = type === 'blossom' ? 0xFF69B4 : type === 'bubbles' ? 0x87CEEB : 0x9ACD32; self.graphics = self.attachAsset(type, { anchorX: 0.5, anchorY: 0.5 }); self.nameText = new Text2(type.toUpperCase(), { size: 40, fill: 0x000000 }); self.nameText.anchor.set(0.5, 0.5); self.nameText.y = -120; self.addChild(self.nameText); self.statusText = new Text2('SLEEPING', { size: 30, fill: 0x666666 }); self.statusText.anchor.set(0.5, 0.5); self.statusText.y = 120; self.addChild(self.statusText); self.updateStatus = function (status) { self.statusText.setText(status); }; self.down = function (x, y, obj) { if (currentPhase === 'wake' && self.state === 'sleeping') { self.wakeUp(); } else if (currentPhase === 'comfort' && self.isCrying) { self.startComfort(); } else if (currentPhase === 'diaper' && !self.diaperChanged) { self.changeDiaper(); } else if (currentPhase === 'bathroom' && !self.bathroomDone) { self.useBathroom(); } }; self.wakeUp = function () { self.state = 'awake'; self.updateStatus('AWAKE'); self.graphics.alpha = 1.0; LK.getSound('wakeup').play(); checkPhaseComplete(); }; self.startComfort = function () { self.comfortTime = 0; self.updateStatus('BEING COMFORTED'); LK.getSound('comfort').play(); }; self.changeDiaper = function () { self.diaperChanged = true; self.updateStatus('DIAPER CHANGED'); LK.getSound('diaper').play(); checkPhaseComplete(); }; self.useBathroom = function () { self.bathroomDone = true; self.updateStatus('BATHROOM DONE'); checkPhaseComplete(); }; self.update = function () { if (self.state === 'sleeping') { self.graphics.alpha = 0.5 + 0.3 * Math.sin(LK.ticks * 0.05); } if (currentPhase === 'comfort' && self.isCrying && self.comfortTime > 0) { self.comfortTime++; if (self.comfortTime > 60) { self.isCrying = false; self.updateStatus('COMFORTED'); checkPhaseComplete(); } } }; return self; }); var Milk = Container.expand(function () { var self = Container.call(this); self.graphics = self.attachAsset('milk', { anchorX: 0.5, anchorY: 0.5 }); self.isDragging = false; self.startX = 0; self.startY = 0; self.down = function (x, y, obj) { if (currentPhase === 'feeding') { self.isDragging = true; self.startX = self.x; self.startY = self.y; draggedItem = self; } }; return self; }); var Spoon = Container.expand(function () { var self = Container.call(this); self.graphics = self.attachAsset('spoon', { anchorX: 0.5, anchorY: 0.5 }); self.isDragging = false; self.startX = 0; self.startY = 0; self.down = function (x, y, obj) { if (currentPhase === 'feeding' && milkPhaseComplete) { self.isDragging = true; self.startX = self.x; self.startY = self.y; draggedItem = self; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xFFE4E1 }); /**** * Game Code ****/ var currentPhase = 'wake'; var girls = []; var milkItems = []; var spoons = []; var bubbles = []; var draggedItem = null; var milkPhaseComplete = false; var bubblesPopped = 0; // Phase tracking var phases = ['wake', 'feeding', 'comfort', 'diaper', 'bathroom', 'bath', 'complete']; var currentPhaseIndex = 0; // UI Elements var phaseText = new Text2('WAKE UP THE GIRLS', { size: 60, fill: 0x000000 }); phaseText.anchor.set(0.5, 0.5); LK.gui.top.addChild(phaseText); phaseText.y = 100; var progressText = new Text2('Tap the girls to wake them up', { size: 40, fill: 0x666666 }); progressText.anchor.set(0.5, 0.5); LK.gui.top.addChild(progressText); progressText.y = 180; // Create girls var blossom = new Girl('blossom'); blossom.x = 2048 * 0.25; blossom.y = 1000; game.addChild(blossom); girls.push(blossom); var bubblesGirl = new Girl('bubbles'); bubblesGirl.x = 2048 * 0.5; bubblesGirl.y = 1000; game.addChild(bubblesGirl); girls.push(bubblesGirl); var buttercup = new Girl('buttercup'); buttercup.x = 2048 * 0.75; buttercup.y = 1000; game.addChild(buttercup); girls.push(buttercup); function checkPhaseComplete() { if (currentPhase === 'wake') { var allAwake = girls.every(function (girl) { return girl.state === 'awake'; }); if (allAwake) { nextPhase(); } } else if (currentPhase === 'feeding') { if (!milkPhaseComplete) { var allMilkFed = girls.every(function (girl) { return girl.milkCount >= 3; }); if (allMilkFed) { milkPhaseComplete = true; updatePhaseUI(); } } else { var allPorridgeFed = girls.every(function (girl) { return girl.porridgeCount >= 3; }); if (allPorridgeFed) { nextPhase(); } } } else if (currentPhase === 'comfort') { var allComforted = girls.every(function (girl) { return !girl.isCrying; }); if (allComforted) { nextPhase(); } } else if (currentPhase === 'diaper') { var allDiaperChanged = girls.every(function (girl) { return girl.diaperChanged; }); if (allDiaperChanged) { nextPhase(); } } else if (currentPhase === 'bathroom') { var allBathroomDone = girls.every(function (girl) { return girl.bathroomDone; }); if (allBathroomDone) { nextPhase(); } } else if (currentPhase === 'bath') { if (bubblesPopped >= 6) { nextPhase(); } } } function nextPhase() { currentPhaseIndex++; if (currentPhaseIndex >= phases.length) { currentPhase = 'complete'; phaseText.setText('DAYCARE COMPLETE!'); progressText.setText('All girls are happy and cared for!'); LK.showYouWin(); return; } currentPhase = phases[currentPhaseIndex]; // Clear previous phase items for (var i = milkItems.length - 1; i >= 0; i--) { milkItems[i].destroy(); } milkItems = []; for (var i = spoons.length - 1; i >= 0; i--) { spoons[i].destroy(); } spoons = []; for (var i = bubbles.length - 1; i >= 0; i--) { bubbles[i].destroy(); } bubbles = []; setupPhase(); } function setupPhase() { if (currentPhase === 'feeding') { setupFeedingPhase(); } else if (currentPhase === 'comfort') { setupComfortPhase(); } else if (currentPhase === 'diaper') { setupDiaperPhase(); } else if (currentPhase === 'bathroom') { setupBathroomPhase(); } else if (currentPhase === 'bath') { setupBathPhase(); } updatePhaseUI(); } function setupFeedingPhase() { // Create milk items for (var i = 0; i < 9; i++) { var milk = new Milk(); milk.x = 200 + i % 3 * 150; milk.y = 1400 + Math.floor(i / 3) * 100; game.addChild(milk); milkItems.push(milk); } // Create spoons for (var i = 0; i < 3; i++) { var spoon = new Spoon(); spoon.x = 1500 + i * 100; spoon.y = 1500; game.addChild(spoon); spoons.push(spoon); } } function setupComfortPhase() { girls.forEach(function (girl) { girl.isCrying = true; girl.updateStatus('CRYING'); girl.comfortTime = 0; }); } function setupDiaperPhase() { girls.forEach(function (girl) { girl.diaperChanged = false; girl.updateStatus('NEEDS DIAPER CHANGE'); }); } function setupBathroomPhase() { girls.forEach(function (girl) { girl.bathroomDone = false; girl.updateStatus('NEEDS BATHROOM'); }); } function setupBathPhase() { bubblesPopped = 0; // Create bubbles for (var i = 0; i < 6; i++) { var bubble = new Bubble(); bubble.x = 400 + i % 3 * 400; bubble.y = 1600 + Math.floor(i / 3) * 150; game.addChild(bubble); bubbles.push(bubble); } girls.forEach(function (girl) { girl.updateStatus('IN BATH'); }); } function updatePhaseUI() { if (currentPhase === 'feeding') { if (!milkPhaseComplete) { phaseText.setText('FEEDING TIME - MILK'); progressText.setText('Drag milk to each girl (3 each)'); } else { phaseText.setText('FEEDING TIME - PORRIDGE'); progressText.setText('Drag spoons to feed porridge (3 each)'); } } else if (currentPhase === 'comfort') { phaseText.setText('COMFORT TIME'); progressText.setText('Tap and hold crying girls to comfort them'); } else if (currentPhase === 'diaper') { phaseText.setText('DIAPER CHANGE'); progressText.setText('Tap each girl to change their diaper'); } else if (currentPhase === 'bathroom') { phaseText.setText('BATHROOM TIME'); progressText.setText('Tap each girl to help with bathroom'); } else if (currentPhase === 'bath') { phaseText.setText('BATH TIME'); progressText.setText('Pop 6 bubbles by tapping them'); } } game.move = function (x, y, obj) { if (draggedItem) { draggedItem.x = x; draggedItem.y = y; } }; game.up = function (x, y, obj) { if (draggedItem) { var item = draggedItem; draggedItem = null; // Check if item was dropped on a girl var droppedOnGirl = false; girls.forEach(function (girl) { if (item.intersects(girl)) { droppedOnGirl = true; if (item instanceof Milk && girl.milkCount < 3) { girl.milkCount++; girl.updateStatus('MILK: ' + girl.milkCount + '/3'); LK.getSound('feed').play(); // Remove milk item var index = milkItems.indexOf(item); if (index !== -1) { milkItems.splice(index, 1); item.destroy(); } checkPhaseComplete(); } else if (item instanceof Spoon && girl.porridgeCount < 3 && milkPhaseComplete) { girl.porridgeCount++; girl.updateStatus('PORRIDGE: ' + girl.porridgeCount + '/3'); LK.getSound('feed').play(); // Reset spoon position item.x = item.startX; item.y = item.startY; checkPhaseComplete(); } } }); // Reset position if not dropped on valid target if (!droppedOnGirl && item.startX !== undefined) { item.x = item.startX; item.y = item.startY; } } }; game.update = function () { // Update all girls girls.forEach(function (girl) { girl.update(); }); // Update bubbles bubbles.forEach(function (bubble) { bubble.update(); }); }; // Initialize first phase updatePhaseUI();
/****
* Classes
****/
var Bubble = Container.expand(function () {
var self = Container.call(this);
self.graphics = self.attachAsset('bubble', {
anchorX: 0.5,
anchorY: 0.5
});
self.popped = false;
self.down = function (x, y, obj) {
if (currentPhase === 'bath' && !self.popped) {
self.popped = true;
self.graphics.alpha = 0;
LK.getSound('bubble').play();
bubblesPopped++;
checkPhaseComplete();
}
};
self.update = function () {
if (!self.popped) {
self.graphics.alpha = 0.7 + 0.3 * Math.sin(LK.ticks * 0.1 + self.x * 0.01);
}
};
return self;
});
var Girl = Container.expand(function (type) {
var self = Container.call(this);
self.type = type;
self.state = 'sleeping';
self.milkCount = 0;
self.porridgeCount = 0;
self.isCrying = false;
self.diaperChanged = false;
self.bathroomDone = false;
self.bathDone = false;
self.comfortTime = 0;
var color = type === 'blossom' ? 0xFF69B4 : type === 'bubbles' ? 0x87CEEB : 0x9ACD32;
self.graphics = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
self.nameText = new Text2(type.toUpperCase(), {
size: 40,
fill: 0x000000
});
self.nameText.anchor.set(0.5, 0.5);
self.nameText.y = -120;
self.addChild(self.nameText);
self.statusText = new Text2('SLEEPING', {
size: 30,
fill: 0x666666
});
self.statusText.anchor.set(0.5, 0.5);
self.statusText.y = 120;
self.addChild(self.statusText);
self.updateStatus = function (status) {
self.statusText.setText(status);
};
self.down = function (x, y, obj) {
if (currentPhase === 'wake' && self.state === 'sleeping') {
self.wakeUp();
} else if (currentPhase === 'comfort' && self.isCrying) {
self.startComfort();
} else if (currentPhase === 'diaper' && !self.diaperChanged) {
self.changeDiaper();
} else if (currentPhase === 'bathroom' && !self.bathroomDone) {
self.useBathroom();
}
};
self.wakeUp = function () {
self.state = 'awake';
self.updateStatus('AWAKE');
self.graphics.alpha = 1.0;
LK.getSound('wakeup').play();
checkPhaseComplete();
};
self.startComfort = function () {
self.comfortTime = 0;
self.updateStatus('BEING COMFORTED');
LK.getSound('comfort').play();
};
self.changeDiaper = function () {
self.diaperChanged = true;
self.updateStatus('DIAPER CHANGED');
LK.getSound('diaper').play();
checkPhaseComplete();
};
self.useBathroom = function () {
self.bathroomDone = true;
self.updateStatus('BATHROOM DONE');
checkPhaseComplete();
};
self.update = function () {
if (self.state === 'sleeping') {
self.graphics.alpha = 0.5 + 0.3 * Math.sin(LK.ticks * 0.05);
}
if (currentPhase === 'comfort' && self.isCrying && self.comfortTime > 0) {
self.comfortTime++;
if (self.comfortTime > 60) {
self.isCrying = false;
self.updateStatus('COMFORTED');
checkPhaseComplete();
}
}
};
return self;
});
var Milk = Container.expand(function () {
var self = Container.call(this);
self.graphics = self.attachAsset('milk', {
anchorX: 0.5,
anchorY: 0.5
});
self.isDragging = false;
self.startX = 0;
self.startY = 0;
self.down = function (x, y, obj) {
if (currentPhase === 'feeding') {
self.isDragging = true;
self.startX = self.x;
self.startY = self.y;
draggedItem = self;
}
};
return self;
});
var Spoon = Container.expand(function () {
var self = Container.call(this);
self.graphics = self.attachAsset('spoon', {
anchorX: 0.5,
anchorY: 0.5
});
self.isDragging = false;
self.startX = 0;
self.startY = 0;
self.down = function (x, y, obj) {
if (currentPhase === 'feeding' && milkPhaseComplete) {
self.isDragging = true;
self.startX = self.x;
self.startY = self.y;
draggedItem = self;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xFFE4E1
});
/****
* Game Code
****/
var currentPhase = 'wake';
var girls = [];
var milkItems = [];
var spoons = [];
var bubbles = [];
var draggedItem = null;
var milkPhaseComplete = false;
var bubblesPopped = 0;
// Phase tracking
var phases = ['wake', 'feeding', 'comfort', 'diaper', 'bathroom', 'bath', 'complete'];
var currentPhaseIndex = 0;
// UI Elements
var phaseText = new Text2('WAKE UP THE GIRLS', {
size: 60,
fill: 0x000000
});
phaseText.anchor.set(0.5, 0.5);
LK.gui.top.addChild(phaseText);
phaseText.y = 100;
var progressText = new Text2('Tap the girls to wake them up', {
size: 40,
fill: 0x666666
});
progressText.anchor.set(0.5, 0.5);
LK.gui.top.addChild(progressText);
progressText.y = 180;
// Create girls
var blossom = new Girl('blossom');
blossom.x = 2048 * 0.25;
blossom.y = 1000;
game.addChild(blossom);
girls.push(blossom);
var bubblesGirl = new Girl('bubbles');
bubblesGirl.x = 2048 * 0.5;
bubblesGirl.y = 1000;
game.addChild(bubblesGirl);
girls.push(bubblesGirl);
var buttercup = new Girl('buttercup');
buttercup.x = 2048 * 0.75;
buttercup.y = 1000;
game.addChild(buttercup);
girls.push(buttercup);
function checkPhaseComplete() {
if (currentPhase === 'wake') {
var allAwake = girls.every(function (girl) {
return girl.state === 'awake';
});
if (allAwake) {
nextPhase();
}
} else if (currentPhase === 'feeding') {
if (!milkPhaseComplete) {
var allMilkFed = girls.every(function (girl) {
return girl.milkCount >= 3;
});
if (allMilkFed) {
milkPhaseComplete = true;
updatePhaseUI();
}
} else {
var allPorridgeFed = girls.every(function (girl) {
return girl.porridgeCount >= 3;
});
if (allPorridgeFed) {
nextPhase();
}
}
} else if (currentPhase === 'comfort') {
var allComforted = girls.every(function (girl) {
return !girl.isCrying;
});
if (allComforted) {
nextPhase();
}
} else if (currentPhase === 'diaper') {
var allDiaperChanged = girls.every(function (girl) {
return girl.diaperChanged;
});
if (allDiaperChanged) {
nextPhase();
}
} else if (currentPhase === 'bathroom') {
var allBathroomDone = girls.every(function (girl) {
return girl.bathroomDone;
});
if (allBathroomDone) {
nextPhase();
}
} else if (currentPhase === 'bath') {
if (bubblesPopped >= 6) {
nextPhase();
}
}
}
function nextPhase() {
currentPhaseIndex++;
if (currentPhaseIndex >= phases.length) {
currentPhase = 'complete';
phaseText.setText('DAYCARE COMPLETE!');
progressText.setText('All girls are happy and cared for!');
LK.showYouWin();
return;
}
currentPhase = phases[currentPhaseIndex];
// Clear previous phase items
for (var i = milkItems.length - 1; i >= 0; i--) {
milkItems[i].destroy();
}
milkItems = [];
for (var i = spoons.length - 1; i >= 0; i--) {
spoons[i].destroy();
}
spoons = [];
for (var i = bubbles.length - 1; i >= 0; i--) {
bubbles[i].destroy();
}
bubbles = [];
setupPhase();
}
function setupPhase() {
if (currentPhase === 'feeding') {
setupFeedingPhase();
} else if (currentPhase === 'comfort') {
setupComfortPhase();
} else if (currentPhase === 'diaper') {
setupDiaperPhase();
} else if (currentPhase === 'bathroom') {
setupBathroomPhase();
} else if (currentPhase === 'bath') {
setupBathPhase();
}
updatePhaseUI();
}
function setupFeedingPhase() {
// Create milk items
for (var i = 0; i < 9; i++) {
var milk = new Milk();
milk.x = 200 + i % 3 * 150;
milk.y = 1400 + Math.floor(i / 3) * 100;
game.addChild(milk);
milkItems.push(milk);
}
// Create spoons
for (var i = 0; i < 3; i++) {
var spoon = new Spoon();
spoon.x = 1500 + i * 100;
spoon.y = 1500;
game.addChild(spoon);
spoons.push(spoon);
}
}
function setupComfortPhase() {
girls.forEach(function (girl) {
girl.isCrying = true;
girl.updateStatus('CRYING');
girl.comfortTime = 0;
});
}
function setupDiaperPhase() {
girls.forEach(function (girl) {
girl.diaperChanged = false;
girl.updateStatus('NEEDS DIAPER CHANGE');
});
}
function setupBathroomPhase() {
girls.forEach(function (girl) {
girl.bathroomDone = false;
girl.updateStatus('NEEDS BATHROOM');
});
}
function setupBathPhase() {
bubblesPopped = 0;
// Create bubbles
for (var i = 0; i < 6; i++) {
var bubble = new Bubble();
bubble.x = 400 + i % 3 * 400;
bubble.y = 1600 + Math.floor(i / 3) * 150;
game.addChild(bubble);
bubbles.push(bubble);
}
girls.forEach(function (girl) {
girl.updateStatus('IN BATH');
});
}
function updatePhaseUI() {
if (currentPhase === 'feeding') {
if (!milkPhaseComplete) {
phaseText.setText('FEEDING TIME - MILK');
progressText.setText('Drag milk to each girl (3 each)');
} else {
phaseText.setText('FEEDING TIME - PORRIDGE');
progressText.setText('Drag spoons to feed porridge (3 each)');
}
} else if (currentPhase === 'comfort') {
phaseText.setText('COMFORT TIME');
progressText.setText('Tap and hold crying girls to comfort them');
} else if (currentPhase === 'diaper') {
phaseText.setText('DIAPER CHANGE');
progressText.setText('Tap each girl to change their diaper');
} else if (currentPhase === 'bathroom') {
phaseText.setText('BATHROOM TIME');
progressText.setText('Tap each girl to help with bathroom');
} else if (currentPhase === 'bath') {
phaseText.setText('BATH TIME');
progressText.setText('Pop 6 bubbles by tapping them');
}
}
game.move = function (x, y, obj) {
if (draggedItem) {
draggedItem.x = x;
draggedItem.y = y;
}
};
game.up = function (x, y, obj) {
if (draggedItem) {
var item = draggedItem;
draggedItem = null;
// Check if item was dropped on a girl
var droppedOnGirl = false;
girls.forEach(function (girl) {
if (item.intersects(girl)) {
droppedOnGirl = true;
if (item instanceof Milk && girl.milkCount < 3) {
girl.milkCount++;
girl.updateStatus('MILK: ' + girl.milkCount + '/3');
LK.getSound('feed').play();
// Remove milk item
var index = milkItems.indexOf(item);
if (index !== -1) {
milkItems.splice(index, 1);
item.destroy();
}
checkPhaseComplete();
} else if (item instanceof Spoon && girl.porridgeCount < 3 && milkPhaseComplete) {
girl.porridgeCount++;
girl.updateStatus('PORRIDGE: ' + girl.porridgeCount + '/3');
LK.getSound('feed').play();
// Reset spoon position
item.x = item.startX;
item.y = item.startY;
checkPhaseComplete();
}
}
});
// Reset position if not dropped on valid target
if (!droppedOnGirl && item.startX !== undefined) {
item.x = item.startX;
item.y = item.startY;
}
}
};
game.update = function () {
// Update all girls
girls.forEach(function (girl) {
girl.update();
});
// Update bubbles
bubbles.forEach(function (bubble) {
bubble.update();
});
};
// Initialize first phase
updatePhaseUI();