User prompt
Make toys spawn faster over time (but very slowly)
User prompt
Add golden toys which spawn after 33 seconds at a random place and don’t move and when you tap them maxWrong increases by 1
User prompt
Make a variable which keeps track of how much can you get wrong
User prompt
Add three types of golden toys that can make you get 1 more wrong (etc. Before: Wrong: 2/3 after: Wrong: 2/4
User prompt
Remove the “You win!” And instead make the game infinite
User prompt
The clock boost duration should be 8.75 seconds
User prompt
Make clock very rare
User prompt
The clock does not affect toys that already spawned, only new toys get affected.
User prompt
Make the clock be dynamic to the speed that the time affects
User prompt
Make clocks only spawn when brown toys can spawn and make it much less common
User prompt
Make all sounds preloaded
User prompt
The clock does not play the sound “clockRing”
User prompt
The clock does not work
User prompt
Make the sound “warning” not play when the green box spawns, instead only the “greenBox” sound should play.
User prompt
Make sure to check that the clock is already tapped or not because it might shake too fast or make everything super fast
User prompt
Make the clock shake when tapping it the disappear only after 3 seconds and also play the sound “clockRing” ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Add clocks that appear sometimes on the screen, not moving. When you tap them, everything gets 1.5x faster but score is 3x more.
User prompt
Add an accuracy counter which is yellow at the right of the score counter. It updates to be higher at putting toys in correct boxes, but when you put toys in incorrect boxes or put brown toys in boxes then it decreases. It has % on the end. When toys fall off the screen it should not decrease.
User prompt
The phase counter is always empty or cannot be seen
User prompt
It still can’t be seen
User prompt
I can’t see the phase counter
User prompt
Make the phase counter say “Phase: 1” at start and not be empty
User prompt
Add a yellow counter at the right of the score counter which keeps track of phases. Phase 1 is the start, phase 2 is when the brown toys start spawning, phase 3 is when the green box spawns.
User prompt
Play the sound “greenBox” when the green box spawns
User prompt
Add a sound asset that plays when the green box spawns
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Box = Container.expand(function (color) {
var self = Container.call(this);
self.color = color;
var assetName = color + 'Box';
var boxGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var Clock = Container.expand(function () {
var self = Container.call(this);
var clockGraphics = self.attachAsset('clock', {
anchorX: 0.5,
anchorY: 0.5
});
self.isTapped = false;
self.down = function (x, y, obj) {
if (!self.isTapped) {
self.isTapped = true;
gameSpeed *= 1.5;
scoreMultiplier = 3;
// Update speed of all existing toys
for (var i = 0; i < toys.length; i++) {
toys[i].speed *= 1.5;
}
LK.getSound('clockRing').play();
// Shake animation
tween(self, {
rotation: 0.1
}, {
duration: 100,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(self, {
rotation: -0.1
}, {
duration: 100,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(self, {
rotation: 0
}, {
duration: 100,
easing: tween.easeInOut
});
}
});
}
});
LK.setTimeout(function () {
gameSpeed /= 1.5;
scoreMultiplier = 1;
// Update speed of all existing toys back to normal
for (var i = 0; i < toys.length; i++) {
toys[i].speed /= 1.5;
}
self.destroy();
clockSpawned = false;
}, 8750); // Delay disappearance by 8.75 seconds
}
};
return self;
});
var Toy = Container.expand(function (color) {
var self = Container.call(this);
self.color = color;
self.speed = 3;
self.isDragging = false;
self.startX = 0;
self.startY = 0;
// Randomly select a toy variant (1, 2, or 3)
var variant = Math.floor(Math.random() * 3) + 1;
var assetName = color + 'Toy' + (variant === 1 ? '' : variant);
var toyGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
if (!self.isDragging && !gameOver) {
self.y += self.speed;
if (self.color === 'red' && assetName === 'redToy3') {
self.rotation += 0.1; // Adjust the rotation speed as needed
}
}
};
self.down = function (x, y, obj) {
if (!draggedToy && !gameOver) {
self.isDragging = true;
self.startX = self.x;
self.startY = self.y;
draggedToy = self;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x006600
});
/****
* Game Code
****/
// Create background
var background = LK.getAsset('background', {
anchorX: 0,
anchorY: 0,
scaleX: 20.48,
scaleY: 27.32
});
background.x = 0;
background.y = 0;
game.addChild(background);
// Game variables
var toys = [];
var boxes = [];
var draggedToy = null;
var wrong = 0;
var maxWrong = 3;
var spawnTimer = 0;
var spawnDelay = 90;
var baseSpawnDelay = 90;
var gameSpeed = 1;
var speedIncreaseTimer = 0;
var spawnRateIncreaseTimer = 0;
var gameTimer = 0;
var gameOver = false;
var scoreMilestonePlayed = false;
var fastMusicPlaying = false;
var warningPlayed = false;
// Create boxes at bottom of screen
var boxColors = ['red', 'yellow', 'blue'];
// Center the boxes when green box is not spawned with spacing between them
var boxSpacing = 450; // Distance between boxes
var startX = 2048 / 2 - boxSpacing; // Start position for first box
var boxPositions = [startX, startX + boxSpacing, startX + boxSpacing * 2];
var greenBoxSpawned = false;
for (var i = 0; i < boxColors.length; i++) {
var box = new Box(boxColors[i]);
box.x = boxPositions[i];
box.y = 2732 - 200;
boxes.push(box);
game.addChild(box);
}
// UI Elements
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var healthTxt = new Text2('Wrong: 0/' + maxWrong, {
size: 80,
fill: 0xFF0000
});
healthTxt.anchor.set(0, 0);
healthTxt.x = 150;
healthTxt.y = 20;
LK.gui.topLeft.addChild(healthTxt);
// Spawn toy function
function spawnToy() {
if (gameOver) return;
var availableColors = boxColors.slice();
// Add brown toys after 25 seconds (1500 ticks at 60fps) but less frequently
if (gameTimer >= 1500 && Math.random() < 0.3) {
availableColors.push('brown');
}
// Add green toys after 60 seconds (3600 ticks at 60fps)
if (gameTimer >= 3600) {
availableColors.push('green');
}
var randomColor = availableColors[Math.floor(Math.random() * availableColors.length)];
var toy = new Toy(randomColor);
toy.x = Math.random() * (2048 - 240) + 120;
toy.y = -60;
toy.speed = 3 * gameSpeed;
toys.push(toy);
game.addChild(toy);
}
// Check if toy intersects with any box
function checkToyBoxIntersection(toy) {
for (var i = 0; i < boxes.length; i++) {
if (toy.intersects(boxes[i])) {
return boxes[i];
}
}
return null;
}
// Remove toy from game
function removeToy(toy, index) {
toy.destroy();
toys.splice(index, 1);
}
// Game input handlers
game.move = function (x, y, obj) {
if (draggedToy && !gameOver) {
draggedToy.x = x;
draggedToy.y = y;
}
};
game.up = function (x, y, obj) {
if (draggedToy && !gameOver) {
var intersectingBox = checkToyBoxIntersection(draggedToy);
if (intersectingBox) {
if (draggedToy.color === intersectingBox.color) {
// Correct placement
LK.setScore(LK.getScore() + 5 * scoreMultiplier);
scoreTxt.setText('Score: ' + LK.getScore());
LK.getSound('correct').play();
// Remove toy
var toyIndex = toys.indexOf(draggedToy);
if (toyIndex !== -1) {
removeToy(draggedToy, toyIndex);
}
} else {
// Wrong placement (including brown toys in any box)
var newScore = Math.max(0, LK.getScore() - 15);
LK.setScore(newScore);
scoreTxt.setText('Score: ' + LK.getScore());
wrong++;
healthTxt.setText('Wrong: ' + wrong + '/' + maxWrong);
LK.getSound('wrong').play();
LK.effects.flashScreen(0xff0000, 500);
// Remove brown toys when placed in any box, return others to position
if (draggedToy.color === 'brown') {
var toyIndex = toys.indexOf(draggedToy);
if (toyIndex !== -1) {
removeToy(draggedToy, toyIndex);
}
} else {
// Return toy to original position
draggedToy.x = draggedToy.startX;
draggedToy.y = draggedToy.startY;
}
}
} else {
// Return toy to original position if not dropped on box
draggedToy.x = draggedToy.startX;
draggedToy.y = draggedToy.startY;
}
draggedToy.isDragging = false;
draggedToy = null;
}
};
// Main game update
game.update = function () {
if (gameOver) return;
// Update game timer
gameTimer++;
// Spawn toys
spawnTimer++;
if (spawnTimer >= spawnDelay) {
spawnToy();
spawnTimer = 0;
}
// Increase game speed over time
speedIncreaseTimer++;
if (speedIncreaseTimer >= 240) {
// Every 4 seconds at 60fps
gameSpeed *= 1.03; // Increase by 3%
if (gameSpeed > 3.0) {
gameSpeed = 3.0; // Cap at 300% (3x original speed)
}
speedIncreaseTimer = 0;
}
// Increase spawn rate over time (separate from speed increase)
spawnRateIncreaseTimer++;
if (spawnRateIncreaseTimer >= 1800) {
// Every 30 seconds at 60fps
if (spawnDelay > 30) {
spawnDelay = Math.max(30, spawnDelay - 2); // Reduce spawn delay by 2, minimum 30
}
spawnRateIncreaseTimer = 0;
}
// Start fast music when speed reaches maximum
if (gameSpeed >= 3.0 && !fastMusicPlaying) {
LK.playMusic('fastMusic');
fastMusicPlaying = true;
}
// Occasionally spawn clocks (only when brown toys can spawn and much less common)
if (gameTimer >= 1500 && Math.random() < 0.001 && !clockSpawned) {
var clock = new Clock();
clock.x = Math.random() * (2048 - 200) + 100;
clock.y = Math.random() * (2732 - 200) + 100;
game.addChild(clock);
clockSpawned = true;
}
// Update toys and check for collisions/missed toys
for (var i = toys.length - 1; i >= 0; i--) {
var toy = toys[i];
// Check if toy fell off screen
if (toy.y > 2732 + 60) {
// Brown toys don't give penalty when falling off screen - just remove them
if (toy.color !== 'brown') {
// Non-brown toys give penalty when falling off screen
var newScore = Math.max(0, LK.getScore() - 15);
LK.setScore(newScore);
scoreTxt.setText('Score: ' + LK.getScore());
wrong++;
healthTxt.setText('Wrong: ' + wrong + '/' + maxWrong);
LK.getSound('wrong').play();
LK.effects.flashScreen(0xff0000, 500);
}
removeToy(toy, i);
continue;
}
// Check if toy is intersecting with correct box while not being dragged
if (!toy.isDragging) {
var intersectingBox = checkToyBoxIntersection(toy);
if (intersectingBox) {
if (toy.color === intersectingBox.color) {
LK.setScore(LK.getScore() + 5 * scoreMultiplier);
scoreTxt.setText('Score: ' + LK.getScore());
LK.getSound('correct').play();
removeToy(toy, i);
continue;
}
}
}
}
// Check game over condition
if (wrong >= maxWrong && !gameOver) {
gameOver = true;
// Stop all music when santa appears
LK.stopMusic();
// Show santa for 1 second before game over
var santa = LK.getAsset('santa', {
anchorX: 0.5,
anchorY: 0.5
});
santa.x = 2048 / 2;
santa.y = 2732 / 2;
game.addChild(santa);
// Play santa sound
LK.getSound('santa').play();
// Calculate scale to make santa almost fill the screen
// Leave some padding around the edges (90% of screen size)
var targetScaleX = 2048 * 0.9 / santa.width;
var targetScaleY = 2732 * 0.9 / santa.height;
// Use the smaller scale to maintain aspect ratio and fit within screen
var targetScale = Math.min(targetScaleX, targetScaleY);
// Animate santa appearing with scale tween
santa.scaleX = 0;
santa.scaleY = 0;
tween(santa, {
scaleX: targetScale,
scaleY: targetScale
}, {
duration: 500,
easing: tween.bounceOut,
onFinish: function onFinish() {
// Wait 1500ms more then show game over (total 2 seconds)
LK.setTimeout(function () {
LK.showGameOver();
}, 1500);
}
});
}
// Play warning 5 seconds before brown toys spawn (at 20 seconds / 1200 ticks)
if (gameTimer >= 1200 && !warningPlayed) {
LK.getSound('warning').play();
warningPlayed = true;
// Create exclamation mark
var exclamation = LK.getAsset('exclamation', {
anchorX: 0.5,
anchorY: 0.5
});
exclamation.x = 2048 / 2;
exclamation.y = 2732 / 2;
exclamation.scaleX = 0;
exclamation.scaleY = 0;
game.addChild(exclamation);
// Animate exclamation mark appearing
tween(exclamation, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.bounceOut,
onFinish: function onFinish() {
// Keep exclamation visible for 2 seconds then fade out
LK.setTimeout(function () {
tween(exclamation, {
alpha: 0,
scaleX: 0,
scaleY: 0
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
exclamation.destroy();
}
});
}, 2000);
}
});
}
// Play warning at 60 seconds (3600 ticks) and spawn green box
if (gameTimer >= 3600 && !greenBoxSpawned) {
greenBoxSpawned = true;
// Move existing boxes to the left with tween animation
for (var b = 0; b < boxes.length; b++) {
var targetX = (b + 1) * 2048 / 5;
tween(boxes[b], {
x: targetX
}, {
duration: 1000,
easing: tween.easeInOut
});
}
// Create green box at the right
LK.getSound('greenBox').play();
var greenBox = new Box('green');
greenBox.x = 4 * 2048 / 5;
greenBox.y = 2732 - 200;
greenBox.alpha = 0; // Start invisible for fade-in animation
boxes.push(greenBox);
boxColors.push('green');
game.addChild(greenBox);
// Animate green box fade in
tween(greenBox, {
alpha: 1
}, {
duration: 1000,
easing: tween.easeInOut
});
// Create exclamation mark
var exclamation = LK.getAsset('exclamation', {
anchorX: 0.5,
anchorY: 0.5
});
exclamation.x = 2048 / 2;
exclamation.y = 2732 / 2;
exclamation.scaleX = 0;
exclamation.scaleY = 0;
game.addChild(exclamation);
// Animate exclamation mark appearing
tween(exclamation, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.bounceOut,
onFinish: function onFinish() {
// Keep exclamation visible for 2 seconds then fade out
LK.setTimeout(function () {
tween(exclamation, {
alpha: 0,
scaleX: 0,
scaleY: 0
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
exclamation.destroy();
}
});
}, 2000);
}
});
}
// Play sound effect when reaching a score of 1000
if (LK.getScore() >= 1000 && !scoreMilestonePlayed) {
LK.getSound('scoreMilestone').play();
scoreMilestonePlayed = true;
}
// Game is now infinite - no win condition
};
// Start background music immediately at game start
LK.playMusic('christmas');
// Preload all sounds by playing them at volume 0
var correctSound = LK.getSound('correct');
correctSound.volume = 0;
correctSound.play();
correctSound.volume = 0.5;
var wrongSound = LK.getSound('wrong');
wrongSound.volume = 0;
wrongSound.play();
wrongSound.volume = 0.5;
var santaSound = LK.getSound('santa');
santaSound.volume = 0;
santaSound.play();
santaSound.volume = 1;
var clockRingSound = LK.getSound('clockRing');
clockRingSound.volume = 0;
clockRingSound.play();
clockRingSound.volume = 0.8;
var greenBoxSound = LK.getSound('greenBox');
greenBoxSound.volume = 0;
greenBoxSound.play();
greenBoxSound.volume = 1;
var scoreMilestoneSound = LK.getSound('scoreMilestone');
scoreMilestoneSound.volume = 0;
scoreMilestoneSound.play();
scoreMilestoneSound.volume = 1;
var warningSound = LK.getSound('warning');
warningSound.volume = 0;
warningSound.play();
warningSound.volume = 1;
var scoreMultiplier = 1;
var clockSpawned = false;
; ===================================================================
--- original.js
+++ change.js
@@ -69,34 +69,8 @@
}
};
return self;
});
-var GoldenToy = Container.expand(function () {
- var self = Container.call(this);
- self.isGolden = true;
- // Randomly select a golden toy variant (1, 2, or 3)
- var variant = Math.floor(Math.random() * 3) + 1;
- var assetName = 'goldenToy' + (variant === 1 ? '' : variant);
- var toyGraphics = self.attachAsset(assetName, {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.down = function (x, y, obj) {
- if (!gameOver) {
- maxWrong++;
- healthTxt.setText('Wrong: ' + wrong + '/' + maxWrong);
- LK.getSound('correct').play();
- LK.effects.flashScreen(0xFFD700, 500); // Golden flash
- self.destroy();
- // Remove from goldenToys array
- var index = goldenToys.indexOf(self);
- if (index !== -1) {
- goldenToys.splice(index, 1);
- }
- }
- };
- return self;
-});
var Toy = Container.expand(function (color) {
var self = Container.call(this);
self.color = color;
self.speed = 3;
@@ -151,16 +125,17 @@
game.addChild(background);
// Game variables
var toys = [];
var boxes = [];
-var goldenToys = [];
var draggedToy = null;
var wrong = 0;
var maxWrong = 3;
var spawnTimer = 0;
var spawnDelay = 90;
+var baseSpawnDelay = 90;
var gameSpeed = 1;
var speedIncreaseTimer = 0;
+var spawnRateIncreaseTimer = 0;
var gameTimer = 0;
var gameOver = false;
var scoreMilestonePlayed = false;
var fastMusicPlaying = false;
@@ -297,12 +272,18 @@
gameSpeed *= 1.03; // Increase by 3%
if (gameSpeed > 3.0) {
gameSpeed = 3.0; // Cap at 300% (3x original speed)
}
+ speedIncreaseTimer = 0;
+ }
+ // Increase spawn rate over time (separate from speed increase)
+ spawnRateIncreaseTimer++;
+ if (spawnRateIncreaseTimer >= 1800) {
+ // Every 30 seconds at 60fps
if (spawnDelay > 30) {
- spawnDelay -= 1;
+ spawnDelay = Math.max(30, spawnDelay - 2); // Reduce spawn delay by 2, minimum 30
}
- speedIncreaseTimer = 0;
+ spawnRateIncreaseTimer = 0;
}
// Start fast music when speed reaches maximum
if (gameSpeed >= 3.0 && !fastMusicPlaying) {
LK.playMusic('fastMusic');
@@ -315,16 +296,8 @@
clock.y = Math.random() * (2732 - 200) + 100;
game.addChild(clock);
clockSpawned = true;
}
- // Spawn golden toys after 33 seconds (1980 ticks at 60fps)
- if (gameTimer >= 1980 && Math.random() < 0.005) {
- var goldenToy = new GoldenToy();
- goldenToy.x = Math.random() * (2048 - 200) + 100;
- goldenToy.y = Math.random() * (2732 - 400) + 200;
- goldenToys.push(goldenToy);
- game.addChild(goldenToy);
- }
// Update toys and check for collisions/missed toys
for (var i = toys.length - 1; i >= 0; i--) {
var toy = toys[i];
// Check if toy fell off screen
Santa angry In-Game asset. 2d. High contrast. No shadows
Brown rocking horse. In-Game asset. 2d. High contrast. No shadows
Brown kids book. In-Game asset. 2d. High contrast. No shadows
A blue robot toy. In-Game asset. 2d. High contrast. No shadows
A yellow box. In-Game asset. 2d. High contrast. No shadows
Yellow star plushie with a smile on it. In-Game asset. 2d. High contrast. No shadows
A red toy car. In-Game asset. 2d. High contrast. No shadows
A yellow banana. In-Game asset. 2d. High contrast. No shadows
Red ball with two white eyes, inside the eyes are medium sized black dots, and a black smiley mouth. In-Game asset. 2d. High contrast. No shadows
Blue diamond toy. In-Game asset. 2d. High contrast
Red exclamation mark with a gradient and a stroke. In-Game asset. 2d. High contrast. No shadows
Green box. In-Game asset. 2d. High contrast. No shadows
Red clock. In-Game asset. 2d. High contrast. No shadows
A green puzzle piece. In-Game asset. 2d. High contrast. No shadows
Green dino plushie. In-Game asset. 2d. High contrast. No shadows
Green apple. In-Game asset. 2d. High contrast. No shadows