/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Ginger = Container.expand(function () {
var self = Container.call(this);
var gingerBody = self.attachAsset('ginger', {
anchorX: 0.5,
anchorY: 1.0
});
var wand = self.addChild(LK.getAsset('wand', {
anchorX: 0.2,
anchorY: 0.5
}));
var wandTip = wand.addChild(LK.getAsset('wandTip', {
anchorX: 0.5,
anchorY: 0.5
}));
wand.x = 60;
wand.y = -120;
wand.rotation = -0.3;
wandTip.x = 80;
self.isPerforming = false;
self.activateWand = function () {
wandActivated = true;
LK.getSound('wandActivate').play();
// Wand glow effect
LK.effects.flashObject(wandTip, 0xffd700, 800);
// Gentle wand wave animation
tween(wand, {
rotation: -0.1
}, {
duration: 400,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(wand, {
rotation: -0.3
}, {
duration: 400
});
}
});
wandText.setText("Magic activated! Touch the stars!");
};
self.startPerformance = function () {
self.isPerforming = true;
// Performance animation - gentle swaying
function sway() {
if (self.isPerforming) {
tween(gingerBody, {
rotation: 0.1
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(gingerBody, {
rotation: -0.1
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: sway
});
}
});
}
}
sway();
// Start singing performance
performSong();
};
wand.down = function (x, y, obj) {
if (!wandActivated) {
self.activateWand();
}
};
return self;
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
self.isLit = false;
self.originalColor = 0xffff99;
self.auroraColors = [0x00bfff, 0x9370db, 0x00ff7f]; // Blue, purple, green
self.currentColorIndex = 0;
self.light = function () {
if (!self.isLit) {
self.isLit = true;
var auroraColor = self.auroraColors[self.currentColorIndex];
starGraphics.tint = auroraColor;
// Scale up animation
tween(starGraphics, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(starGraphics, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200
});
}
});
// Glow effect
LK.effects.flashObject(self, auroraColor, 500);
LK.getSound('starGlow').play();
// Cycle to next aurora color for next star
Star.prototype.nextColorIndex = (Star.prototype.nextColorIndex || 0) + 1;
if (Star.prototype.nextColorIndex >= self.auroraColors.length) {
Star.prototype.nextColorIndex = 0;
}
}
};
self.down = function (x, y, obj) {
if (wandActivated && !self.isLit) {
self.currentColorIndex = Star.prototype.nextColorIndex || 0;
self.light();
starsLit++;
updateProgress();
checkWinCondition();
}
};
self.update = function () {
if (self.isLit) {
// Gentle twinkling effect
var twinkle = Math.sin(LK.ticks * 0.1) * 0.1 + 0.9;
starGraphics.alpha = twinkle;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000428 // Dark night sky blue
});
/****
* Game Code
****/
var wandActivated = false;
var starsLit = 0;
var stars = [];
var ginger;
var progressText;
var wandText;
var performanceText;
var isPerforming = false;
var songIndex = 0;
var songTimer = 0;
// Mary Had a Little Lamb lyrics
var songLyrics = ["♪ Mary had a little lamb ♪", "♪ Little lamb, little lamb ♪", "♪ Mary had a little lamb ♪", "♪ Its fleece was white as snow ♪"];
// Create Ginger character
ginger = game.addChild(new Ginger());
ginger.x = 1024; // Center horizontally
ginger.y = 2500; // Near bottom
// Create stars scattered across the sky
var starPositions = [{
x: 300,
y: 400
}, {
x: 800,
y: 300
}, {
x: 1400,
y: 450
}, {
x: 500,
y: 650
}, {
x: 1200,
y: 600
}, {
x: 1700,
y: 700
}, {
x: 400,
y: 900
}, {
x: 900,
y: 850
}, {
x: 1500,
y: 950
}];
for (var i = 0; i < starPositions.length; i++) {
var star = game.addChild(new Star());
star.x = starPositions[i].x;
star.y = starPositions[i].y;
stars.push(star);
}
// UI Elements
progressText = new Text2('0/9 Stars Lit', {
size: 60,
fill: 0xFFFFFF
});
progressText.anchor.set(0.5, 0);
LK.gui.top.addChild(progressText);
progressText.y = 50;
wandText = new Text2('Tap Ginger\'s wand to begin!', {
size: 50,
fill: 0xFFFF99
});
wandText.anchor.set(0.5, 1);
LK.gui.bottom.addChild(wandText);
wandText.y = -100;
performanceText = new Text2('', {
size: 70,
fill: 0xFF69B4
});
performanceText.anchor.set(0.5, 0.5);
LK.gui.center.addChild(performanceText);
function updateProgress() {
progressText.setText(starsLit + '/9 Stars Lit');
if (starsLit >= 9 && !isPerforming) {
wandText.setText('All stars are glowing! 🌟');
}
}
function checkWinCondition() {
if (starsLit >= 9 && !isPerforming) {
isPerforming = true;
wandText.setText('Ginger is performing for you!');
LK.setTimeout(function () {
ginger.startPerformance();
}, 1000);
}
}
function performSong() {
if (songIndex < songLyrics.length) {
performanceText.setText(songLyrics[songIndex]);
performanceText.alpha = 0;
// Fade in text
tween(performanceText, {
alpha: 1
}, {
duration: 500,
onFinish: function onFinish() {
// Keep text visible for 2 seconds
LK.setTimeout(function () {
// Fade out text
tween(performanceText, {
alpha: 0
}, {
duration: 500,
onFinish: function onFinish() {
songIndex++;
if (songIndex < songLyrics.length) {
LK.setTimeout(function () {
performSong();
}, 500);
} else {
// Song finished, reset game
LK.setTimeout(function () {
resetGame();
}, 2000);
}
}
});
}, 2000);
}
});
// Create aurora effect during performance
createAuroraEffect();
}
}
function createAuroraEffect() {
// Flash screen with gentle aurora colors
var auroraColors = [0x00bfff, 0x9370db, 0x00ff7f];
var color = auroraColors[Math.floor(Math.random() * auroraColors.length)];
LK.effects.flashScreen(color, 1500);
}
function resetGame() {
// Reset all game state
wandActivated = false;
starsLit = 0;
isPerforming = false;
songIndex = 0;
ginger.isPerforming = false;
// Reset all stars
for (var i = 0; i < stars.length; i++) {
stars[i].isLit = false;
var starGraphics = stars[i].children[0];
starGraphics.tint = 0xffff99;
starGraphics.alpha = 1;
starGraphics.scaleX = 1;
starGraphics.scaleY = 1;
}
// Reset UI
updateProgress();
wandText.setText('Tap Ginger\'s wand to begin!');
performanceText.setText('');
// Reset color cycling
Star.prototype.nextColorIndex = 0;
}
game.update = function () {
// Aurora background effects when wand is activated
if (wandActivated && !isPerforming && LK.ticks % 180 == 0) {
var auroraColors = [0x001a4d, 0x1a0033, 0x003d1a];
var color = auroraColors[Math.floor(Math.random() * auroraColors.length)];
LK.effects.flashScreen(color, 2000);
}
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Ginger = Container.expand(function () {
var self = Container.call(this);
var gingerBody = self.attachAsset('ginger', {
anchorX: 0.5,
anchorY: 1.0
});
var wand = self.addChild(LK.getAsset('wand', {
anchorX: 0.2,
anchorY: 0.5
}));
var wandTip = wand.addChild(LK.getAsset('wandTip', {
anchorX: 0.5,
anchorY: 0.5
}));
wand.x = 60;
wand.y = -120;
wand.rotation = -0.3;
wandTip.x = 80;
self.isPerforming = false;
self.activateWand = function () {
wandActivated = true;
LK.getSound('wandActivate').play();
// Wand glow effect
LK.effects.flashObject(wandTip, 0xffd700, 800);
// Gentle wand wave animation
tween(wand, {
rotation: -0.1
}, {
duration: 400,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(wand, {
rotation: -0.3
}, {
duration: 400
});
}
});
wandText.setText("Magic activated! Touch the stars!");
};
self.startPerformance = function () {
self.isPerforming = true;
// Performance animation - gentle swaying
function sway() {
if (self.isPerforming) {
tween(gingerBody, {
rotation: 0.1
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(gingerBody, {
rotation: -0.1
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: sway
});
}
});
}
}
sway();
// Start singing performance
performSong();
};
wand.down = function (x, y, obj) {
if (!wandActivated) {
self.activateWand();
}
};
return self;
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
self.isLit = false;
self.originalColor = 0xffff99;
self.auroraColors = [0x00bfff, 0x9370db, 0x00ff7f]; // Blue, purple, green
self.currentColorIndex = 0;
self.light = function () {
if (!self.isLit) {
self.isLit = true;
var auroraColor = self.auroraColors[self.currentColorIndex];
starGraphics.tint = auroraColor;
// Scale up animation
tween(starGraphics, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(starGraphics, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200
});
}
});
// Glow effect
LK.effects.flashObject(self, auroraColor, 500);
LK.getSound('starGlow').play();
// Cycle to next aurora color for next star
Star.prototype.nextColorIndex = (Star.prototype.nextColorIndex || 0) + 1;
if (Star.prototype.nextColorIndex >= self.auroraColors.length) {
Star.prototype.nextColorIndex = 0;
}
}
};
self.down = function (x, y, obj) {
if (wandActivated && !self.isLit) {
self.currentColorIndex = Star.prototype.nextColorIndex || 0;
self.light();
starsLit++;
updateProgress();
checkWinCondition();
}
};
self.update = function () {
if (self.isLit) {
// Gentle twinkling effect
var twinkle = Math.sin(LK.ticks * 0.1) * 0.1 + 0.9;
starGraphics.alpha = twinkle;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000428 // Dark night sky blue
});
/****
* Game Code
****/
var wandActivated = false;
var starsLit = 0;
var stars = [];
var ginger;
var progressText;
var wandText;
var performanceText;
var isPerforming = false;
var songIndex = 0;
var songTimer = 0;
// Mary Had a Little Lamb lyrics
var songLyrics = ["♪ Mary had a little lamb ♪", "♪ Little lamb, little lamb ♪", "♪ Mary had a little lamb ♪", "♪ Its fleece was white as snow ♪"];
// Create Ginger character
ginger = game.addChild(new Ginger());
ginger.x = 1024; // Center horizontally
ginger.y = 2500; // Near bottom
// Create stars scattered across the sky
var starPositions = [{
x: 300,
y: 400
}, {
x: 800,
y: 300
}, {
x: 1400,
y: 450
}, {
x: 500,
y: 650
}, {
x: 1200,
y: 600
}, {
x: 1700,
y: 700
}, {
x: 400,
y: 900
}, {
x: 900,
y: 850
}, {
x: 1500,
y: 950
}];
for (var i = 0; i < starPositions.length; i++) {
var star = game.addChild(new Star());
star.x = starPositions[i].x;
star.y = starPositions[i].y;
stars.push(star);
}
// UI Elements
progressText = new Text2('0/9 Stars Lit', {
size: 60,
fill: 0xFFFFFF
});
progressText.anchor.set(0.5, 0);
LK.gui.top.addChild(progressText);
progressText.y = 50;
wandText = new Text2('Tap Ginger\'s wand to begin!', {
size: 50,
fill: 0xFFFF99
});
wandText.anchor.set(0.5, 1);
LK.gui.bottom.addChild(wandText);
wandText.y = -100;
performanceText = new Text2('', {
size: 70,
fill: 0xFF69B4
});
performanceText.anchor.set(0.5, 0.5);
LK.gui.center.addChild(performanceText);
function updateProgress() {
progressText.setText(starsLit + '/9 Stars Lit');
if (starsLit >= 9 && !isPerforming) {
wandText.setText('All stars are glowing! 🌟');
}
}
function checkWinCondition() {
if (starsLit >= 9 && !isPerforming) {
isPerforming = true;
wandText.setText('Ginger is performing for you!');
LK.setTimeout(function () {
ginger.startPerformance();
}, 1000);
}
}
function performSong() {
if (songIndex < songLyrics.length) {
performanceText.setText(songLyrics[songIndex]);
performanceText.alpha = 0;
// Fade in text
tween(performanceText, {
alpha: 1
}, {
duration: 500,
onFinish: function onFinish() {
// Keep text visible for 2 seconds
LK.setTimeout(function () {
// Fade out text
tween(performanceText, {
alpha: 0
}, {
duration: 500,
onFinish: function onFinish() {
songIndex++;
if (songIndex < songLyrics.length) {
LK.setTimeout(function () {
performSong();
}, 500);
} else {
// Song finished, reset game
LK.setTimeout(function () {
resetGame();
}, 2000);
}
}
});
}, 2000);
}
});
// Create aurora effect during performance
createAuroraEffect();
}
}
function createAuroraEffect() {
// Flash screen with gentle aurora colors
var auroraColors = [0x00bfff, 0x9370db, 0x00ff7f];
var color = auroraColors[Math.floor(Math.random() * auroraColors.length)];
LK.effects.flashScreen(color, 1500);
}
function resetGame() {
// Reset all game state
wandActivated = false;
starsLit = 0;
isPerforming = false;
songIndex = 0;
ginger.isPerforming = false;
// Reset all stars
for (var i = 0; i < stars.length; i++) {
stars[i].isLit = false;
var starGraphics = stars[i].children[0];
starGraphics.tint = 0xffff99;
starGraphics.alpha = 1;
starGraphics.scaleX = 1;
starGraphics.scaleY = 1;
}
// Reset UI
updateProgress();
wandText.setText('Tap Ginger\'s wand to begin!');
performanceText.setText('');
// Reset color cycling
Star.prototype.nextColorIndex = 0;
}
game.update = function () {
// Aurora background effects when wand is activated
if (wandActivated && !isPerforming && LK.ticks % 180 == 0) {
var auroraColors = [0x001a4d, 0x1a0033, 0x003d1a];
var color = auroraColors[Math.floor(Math.random() * auroraColors.length)];
LK.effects.flashScreen(color, 2000);
}
};