Code edit (1 edits merged)
Please save this source code
User prompt
Baby Dolly Care Adventure
Initial prompt
Toca baby care (2016). Dolly 🦛 is sleeping. Let’s wake her up. Tap on the torch lamp, tap on any pacifier to put it on dolly’s mouth, tap on the mobile to play a lullaby, tap on the mosquito 🦟 faster until it bites dolly 🦛, tap to choose another pacifier to make dolly 🦛 stop crying 😭
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Baby = Container.expand(function () { var self = Container.call(this); var babyGraphics = self.attachAsset('baby', { anchorX: 0.5, anchorY: 0.5 }); self.isAwake = false; self.isCrying = false; self.hasPackifier = false; self.happiness = 100; self.wakeUp = function () { if (!self.isAwake) { self.isAwake = true; tween(babyGraphics, { scaleX: 1.1, scaleY: 1.1 }, { duration: 500, easing: tween.easeOut }); } }; self.startCrying = function () { if (!self.isCrying) { self.isCrying = true; self.hasPackifier = false; LK.getSound('cry').play(); babyGraphics.tint = 0xff6b6b; tween(babyGraphics, { rotation: 0.1 }, { duration: 200, easing: tween.easeInOut, onFinish: function onFinish() { tween(babyGraphics, { rotation: -0.1 }, { duration: 200, easing: tween.easeInOut }); } }); } }; self.stopCrying = function () { if (self.isCrying) { self.isCrying = false; self.hasPackifier = true; babyGraphics.tint = 0xfdbcb4; tween.stop(babyGraphics, { rotation: true }); babyGraphics.rotation = 0; LK.getSound('pacifier').play(); } }; self.update = function () { if (self.isCrying && self.happiness > 0) { self.happiness -= 0.5; } else if (!self.isCrying && self.happiness < 100) { self.happiness += 0.2; } }; return self; }); var Mobile = Container.expand(function () { var self = Container.call(this); var mobileGraphics = self.attachAsset('mobile', { anchorX: 0.5, anchorY: 0.5 }); self.isPlaying = false; self.down = function (x, y, obj) { if (!self.isPlaying) { self.playLullaby(); } }; self.playLullaby = function () { self.isPlaying = true; LK.getSound('lullaby').play(); tween(mobileGraphics, { rotation: Math.PI * 2 }, { duration: 3000, easing: tween.linear, onFinish: function onFinish() { self.isPlaying = false; mobileGraphics.rotation = 0; } }); if (baby && baby.isAwake && !baby.isCrying) { LK.setScore(LK.getScore() + 5); updateUI(); } }; return self; }); var Mosquito = Container.expand(function () { var self = Container.call(this); var mosquitoGraphics = self.attachAsset('mosquito', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.directionX = Math.random() > 0.5 ? 1 : -1; self.directionY = Math.random() > 0.5 ? 1 : -1; self.lifeTime = 0; self.maxLifeTime = 300; // 5 seconds at 60fps self.down = function (x, y, obj) { self.destroy(); for (var i = mosquitoes.length - 1; i >= 0; i--) { if (mosquitoes[i] === self) { mosquitoes.splice(i, 1); break; } } LK.setScore(LK.getScore() + 20); updateUI(); }; self.update = function () { self.x += self.directionX * self.speed; self.y += self.directionY * self.speed; if (self.x <= 50 || self.x >= 1998) { self.directionX *= -1; } if (self.y <= 50 || self.y >= 2682) { self.directionY *= -1; } self.lifeTime++; if (self.lifeTime >= self.maxLifeTime) { if (baby && baby.isAwake) { baby.startCrying(); LK.getSound('mosquito_buzz').play(); } self.destroy(); for (var i = mosquitoes.length - 1; i >= 0; i--) { if (mosquitoes[i] === self) { mosquitoes.splice(i, 1); break; } } } }; return self; }); var Pacifier = Container.expand(function (assetId, color) { var self = Container.call(this); var pacifierGraphics = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); self.color = color; self.down = function (x, y, obj) { if (baby && baby.isAwake && baby.isCrying) { baby.stopCrying(); LK.setScore(LK.getScore() + 10); updateUI(); } }; return self; }); var Torch = Container.expand(function () { var self = Container.call(this); var torchGraphics = self.attachAsset('torch', { anchorX: 0.5, anchorY: 0.5 }); self.isOn = false; self.down = function (x, y, obj) { if (!self.isOn) { self.toggle(); } }; self.toggle = function () { self.isOn = !self.isOn; if (self.isOn) { torchGraphics.tint = 0xffff99; tween(torchGraphics, { scaleX: 1.2, scaleY: 1.2 }, { duration: 300 }); if (lightOverlay) { lightOverlay.alpha = 0.3; tween(lightOverlay, { alpha: 0.6 }, { duration: 500 }); } if (baby) { baby.wakeUp(); } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a2e }); /**** * Game Code ****/ var baby; var torch; var pacifiers = []; var mobile; var mosquitoes = []; var lightOverlay; var scoreText; var happinessText; var mosquitoSpawnTimer = 0; var gamePhase = 'wake'; // 'wake', 'care', 'play' // Create background var background = game.addChild(LK.getAsset('background', { x: 0, y: 0 })); // Create light overlay (initially invisible) lightOverlay = game.addChild(LK.getAsset('light', { x: 0, y: 0, alpha: 0 })); // Create crib var crib = game.addChild(LK.getAsset('crib', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1500 })); // Create baby baby = game.addChild(new Baby()); baby.x = 1024; baby.y = 1400; // Create torch torch = game.addChild(new Torch()); torch.x = 200; torch.y = 400; // Create pacifiers var pacifier1 = new Pacifier('pacifier1', 0xff69b4); pacifier1.x = 300; pacifier1.y = 2200; pacifiers.push(game.addChild(pacifier1)); var pacifier2 = new Pacifier('pacifier2', 0x87ceeb); pacifier2.x = 500; pacifier2.y = 2200; pacifiers.push(game.addChild(pacifier2)); var pacifier3 = new Pacifier('pacifier3', 0x98fb98); pacifier3.x = 700; pacifier3.y = 2200; pacifiers.push(game.addChild(pacifier3)); // Create mobile mobile = game.addChild(new Mobile()); mobile.x = 1024; mobile.y = 800; // Create UI scoreText = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreText.anchor.set(0, 0); LK.gui.top.addChild(scoreText); scoreText.x = 200; scoreText.y = 50; happinessText = new Text2('Happiness: 100', { size: 60, fill: 0xFFFFFF }); happinessText.anchor.set(1, 0); LK.gui.top.addChild(happinessText); happinessText.x = LK.gui.top.width - 50; happinessText.y = 50; function updateUI() { scoreText.setText('Score: ' + LK.getScore()); if (baby) { happinessText.setText('Happiness: ' + Math.floor(baby.happiness)); } } function spawnMosquito() { if (baby && baby.isAwake && mosquitoes.length < 3) { var mosquito = new Mosquito(); mosquito.x = 100 + Math.random() * 1848; mosquito.y = 100 + Math.random() * 1000; mosquitoes.push(game.addChild(mosquito)); } } game.update = function () { // Update baby happiness display updateUI(); // Spawn mosquitoes periodically when baby is awake if (baby && baby.isAwake) { mosquitoSpawnTimer++; if (mosquitoSpawnTimer >= 180) { // Every 3 seconds spawnMosquito(); mosquitoSpawnTimer = 0; } } // Check game over condition if (baby && baby.happiness <= 0) { LK.showGameOver(); } // Check win condition if (LK.getScore() >= 200) { LK.showYouWin(); } }; // Initialize UI updateUI();
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,324 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Baby = Container.expand(function () {
+ var self = Container.call(this);
+ var babyGraphics = self.attachAsset('baby', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.isAwake = false;
+ self.isCrying = false;
+ self.hasPackifier = false;
+ self.happiness = 100;
+ self.wakeUp = function () {
+ if (!self.isAwake) {
+ self.isAwake = true;
+ tween(babyGraphics, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 500,
+ easing: tween.easeOut
+ });
+ }
+ };
+ self.startCrying = function () {
+ if (!self.isCrying) {
+ self.isCrying = true;
+ self.hasPackifier = false;
+ LK.getSound('cry').play();
+ babyGraphics.tint = 0xff6b6b;
+ tween(babyGraphics, {
+ rotation: 0.1
+ }, {
+ duration: 200,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ tween(babyGraphics, {
+ rotation: -0.1
+ }, {
+ duration: 200,
+ easing: tween.easeInOut
+ });
+ }
+ });
+ }
+ };
+ self.stopCrying = function () {
+ if (self.isCrying) {
+ self.isCrying = false;
+ self.hasPackifier = true;
+ babyGraphics.tint = 0xfdbcb4;
+ tween.stop(babyGraphics, {
+ rotation: true
+ });
+ babyGraphics.rotation = 0;
+ LK.getSound('pacifier').play();
+ }
+ };
+ self.update = function () {
+ if (self.isCrying && self.happiness > 0) {
+ self.happiness -= 0.5;
+ } else if (!self.isCrying && self.happiness < 100) {
+ self.happiness += 0.2;
+ }
+ };
+ return self;
+});
+var Mobile = Container.expand(function () {
+ var self = Container.call(this);
+ var mobileGraphics = self.attachAsset('mobile', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.isPlaying = false;
+ self.down = function (x, y, obj) {
+ if (!self.isPlaying) {
+ self.playLullaby();
+ }
+ };
+ self.playLullaby = function () {
+ self.isPlaying = true;
+ LK.getSound('lullaby').play();
+ tween(mobileGraphics, {
+ rotation: Math.PI * 2
+ }, {
+ duration: 3000,
+ easing: tween.linear,
+ onFinish: function onFinish() {
+ self.isPlaying = false;
+ mobileGraphics.rotation = 0;
+ }
+ });
+ if (baby && baby.isAwake && !baby.isCrying) {
+ LK.setScore(LK.getScore() + 5);
+ updateUI();
+ }
+ };
+ return self;
+});
+var Mosquito = Container.expand(function () {
+ var self = Container.call(this);
+ var mosquitoGraphics = self.attachAsset('mosquito', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 2;
+ self.directionX = Math.random() > 0.5 ? 1 : -1;
+ self.directionY = Math.random() > 0.5 ? 1 : -1;
+ self.lifeTime = 0;
+ self.maxLifeTime = 300; // 5 seconds at 60fps
+ self.down = function (x, y, obj) {
+ self.destroy();
+ for (var i = mosquitoes.length - 1; i >= 0; i--) {
+ if (mosquitoes[i] === self) {
+ mosquitoes.splice(i, 1);
+ break;
+ }
+ }
+ LK.setScore(LK.getScore() + 20);
+ updateUI();
+ };
+ self.update = function () {
+ self.x += self.directionX * self.speed;
+ self.y += self.directionY * self.speed;
+ if (self.x <= 50 || self.x >= 1998) {
+ self.directionX *= -1;
+ }
+ if (self.y <= 50 || self.y >= 2682) {
+ self.directionY *= -1;
+ }
+ self.lifeTime++;
+ if (self.lifeTime >= self.maxLifeTime) {
+ if (baby && baby.isAwake) {
+ baby.startCrying();
+ LK.getSound('mosquito_buzz').play();
+ }
+ self.destroy();
+ for (var i = mosquitoes.length - 1; i >= 0; i--) {
+ if (mosquitoes[i] === self) {
+ mosquitoes.splice(i, 1);
+ break;
+ }
+ }
+ }
+ };
+ return self;
+});
+var Pacifier = Container.expand(function (assetId, color) {
+ var self = Container.call(this);
+ var pacifierGraphics = self.attachAsset(assetId, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.color = color;
+ self.down = function (x, y, obj) {
+ if (baby && baby.isAwake && baby.isCrying) {
+ baby.stopCrying();
+ LK.setScore(LK.getScore() + 10);
+ updateUI();
+ }
+ };
+ return self;
+});
+var Torch = Container.expand(function () {
+ var self = Container.call(this);
+ var torchGraphics = self.attachAsset('torch', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.isOn = false;
+ self.down = function (x, y, obj) {
+ if (!self.isOn) {
+ self.toggle();
+ }
+ };
+ self.toggle = function () {
+ self.isOn = !self.isOn;
+ if (self.isOn) {
+ torchGraphics.tint = 0xffff99;
+ tween(torchGraphics, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 300
+ });
+ if (lightOverlay) {
+ lightOverlay.alpha = 0.3;
+ tween(lightOverlay, {
+ alpha: 0.6
+ }, {
+ duration: 500
+ });
+ }
+ if (baby) {
+ baby.wakeUp();
+ }
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x1a1a2e
+});
+
+/****
+* Game Code
+****/
+var baby;
+var torch;
+var pacifiers = [];
+var mobile;
+var mosquitoes = [];
+var lightOverlay;
+var scoreText;
+var happinessText;
+var mosquitoSpawnTimer = 0;
+var gamePhase = 'wake'; // 'wake', 'care', 'play'
+// Create background
+var background = game.addChild(LK.getAsset('background', {
+ x: 0,
+ y: 0
+}));
+// Create light overlay (initially invisible)
+lightOverlay = game.addChild(LK.getAsset('light', {
+ x: 0,
+ y: 0,
+ alpha: 0
+}));
+// Create crib
+var crib = game.addChild(LK.getAsset('crib', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1500
+}));
+// Create baby
+baby = game.addChild(new Baby());
+baby.x = 1024;
+baby.y = 1400;
+// Create torch
+torch = game.addChild(new Torch());
+torch.x = 200;
+torch.y = 400;
+// Create pacifiers
+var pacifier1 = new Pacifier('pacifier1', 0xff69b4);
+pacifier1.x = 300;
+pacifier1.y = 2200;
+pacifiers.push(game.addChild(pacifier1));
+var pacifier2 = new Pacifier('pacifier2', 0x87ceeb);
+pacifier2.x = 500;
+pacifier2.y = 2200;
+pacifiers.push(game.addChild(pacifier2));
+var pacifier3 = new Pacifier('pacifier3', 0x98fb98);
+pacifier3.x = 700;
+pacifier3.y = 2200;
+pacifiers.push(game.addChild(pacifier3));
+// Create mobile
+mobile = game.addChild(new Mobile());
+mobile.x = 1024;
+mobile.y = 800;
+// Create UI
+scoreText = new Text2('Score: 0', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+scoreText.anchor.set(0, 0);
+LK.gui.top.addChild(scoreText);
+scoreText.x = 200;
+scoreText.y = 50;
+happinessText = new Text2('Happiness: 100', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+happinessText.anchor.set(1, 0);
+LK.gui.top.addChild(happinessText);
+happinessText.x = LK.gui.top.width - 50;
+happinessText.y = 50;
+function updateUI() {
+ scoreText.setText('Score: ' + LK.getScore());
+ if (baby) {
+ happinessText.setText('Happiness: ' + Math.floor(baby.happiness));
+ }
+}
+function spawnMosquito() {
+ if (baby && baby.isAwake && mosquitoes.length < 3) {
+ var mosquito = new Mosquito();
+ mosquito.x = 100 + Math.random() * 1848;
+ mosquito.y = 100 + Math.random() * 1000;
+ mosquitoes.push(game.addChild(mosquito));
+ }
+}
+game.update = function () {
+ // Update baby happiness display
+ updateUI();
+ // Spawn mosquitoes periodically when baby is awake
+ if (baby && baby.isAwake) {
+ mosquitoSpawnTimer++;
+ if (mosquitoSpawnTimer >= 180) {
+ // Every 3 seconds
+ spawnMosquito();
+ mosquitoSpawnTimer = 0;
+ }
+ }
+ // Check game over condition
+ if (baby && baby.happiness <= 0) {
+ LK.showGameOver();
+ }
+ // Check win condition
+ if (LK.getScore() >= 200) {
+ LK.showYouWin();
+ }
+};
+// Initialize UI
+updateUI();
\ No newline at end of file