User prompt
WHEN LAVA BUNNY ITEM CLICKED IN SHOP SAY YOU DONT HAVE EGG COINS FOR THIS AND GENARATE A EGG COIN SPRITE NEXT TO IT ADD TEXT THAT SAYS 0 WHEN PLAYER PLAYS THE GAME HOW MANY EGGS HE FINDS THATS HOW MANY EGG COINS HE HAS DO THE SAME THING WITH NINJA BUNNY ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
WHEN LAVA BUNNY ITEM CLICKED IN SHOP TURN THE EASTER BUNNY SPRITE INTO LAVA BUNNY SPRITE HIDE EASTER BUNNY SHOW LAVA BUNNY
User prompt
WHEN LAVA BUNNY ITEM CLICKED GENARATE A IMAGE OF THE LAVA BUNNY REPLACE THE EASTER BUNNY WITH IT
User prompt
MAKE THE BUNNY UPGRADES ITEMS A LAVA BUNNY SKIN AND A NINJA BUNNY SKIN
User prompt
WHEN THE PLAYER CLICKS ON SHOP MAKE A SCREEN WHERE YOU CAN UPGRADE YOUR EASTER BUNNY AND GENARATE A X SPRITE IN A RED SQUARE IF THEY WANT TO GO BACK TO TITLE SCREEN
User prompt
WHEN THE PLAYER IS ON TITLE SCREEN GENARATE SHOP SPRITE
User prompt
WHEN THE PLAYER IS ON TITLE SCREEN GENARTE A EASTER BUNNY SPRITE
User prompt
MAKE THE BACKGROUND GREEN
User prompt
MAKE THE TITLE TEXT WHITE AND IN A RED SQUARE
Code edit (1 edits merged)
Please save this source code
User prompt
Easter Egg Hunt
Initial prompt
FIND THE EGGS WHEN THE PLAYER STARTS THE GAME THEY ARE ON THE TITLE THEY HAVE TO CLICK PLAY GENARTE A PLAY BUTTON SPRITE THEN THE AI HIDES EGGS AND YOU HAVE TO FIND THEM
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var BunnyRunPlayer = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('easterBunny', { anchorX: 0.5, anchorY: 1.0, scaleX: 0.5, scaleY: 0.5 }); var lavaGraphics = self.attachAsset('lavaBunny', { anchorX: 0.5, anchorY: 1.0, scaleX: 0.5, scaleY: 0.5 }); lavaGraphics.visible = false; self.isJumping = false; self.jumpSpeed = 0; self.gravity = 1; self.groundY = 2400; self.transformToLava = function () { playerGraphics.visible = false; lavaGraphics.visible = true; tween(self, { tint: 0xff4444 }, { duration: 300, easing: tween.easeOut }); }; self.transformToNormal = function () { playerGraphics.visible = true; lavaGraphics.visible = false; tween(self, { tint: 0xffffff }, { duration: 300, easing: tween.easeOut }); }; self.update = function () { if (self.isJumping) { self.y += self.jumpSpeed; self.jumpSpeed += self.gravity; if (self.y >= self.groundY) { self.y = self.groundY; self.isJumping = false; self.jumpSpeed = 0; } } }; self.jump = function () { if (!self.isJumping) { self.isJumping = true; self.jumpSpeed = -35; } }; return self; }); var Egg = Container.expand(function (eggType) { var self = Container.call(this); var eggGraphics = self.attachAsset(eggType, { anchorX: 0.5, anchorY: 0.5 }); self.down = function (x, y, obj) { collectEgg(self); }; return self; }); var HighScoreButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('highScoreButton', { anchorX: 0.5, anchorY: 0.5 }); var buttonText = new Text2('HIGH SCORES', { size: 50, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.down = function (x, y, obj) { showHighScores(); }; return self; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 1.0 }); self.update = function () { self.x -= obstacleSpeed; }; return self; }); var PlayButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('playButton', { anchorX: 0.5, anchorY: 0.5 }); var buttonText = new Text2('PLAY', { size: 60, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.down = function (x, y, obj) { startGame(); }; return self; }); var PowerUp = Container.expand(function () { var self = Container.call(this); var powerUpGraphics = self.attachAsset('powerUpSprite', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.x -= obstacleSpeed; }; return self; }); var XButton = Container.expand(function () { var self = Container.call(this); var buttonBackground = self.attachAsset('xButtonBackground', { anchorX: 0.5, anchorY: 0.5 }); var xText = new Text2('X', { size: 80, fill: 0xFFFFFF }); xText.anchor.set(0.5, 0.5); self.addChild(xText); self.down = function (x, y, obj) { closeShop(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x00ff00 }); /**** * Game Code ****/ var gameState = 'title'; // 'title', 'playing', 'shop', or 'bunnyrun' var bunnyRunPlayer; var obstacles = []; var powerUps = []; var bunnyRunSpeed = 5; var obstacleSpeed = 8; var bunnyRunScore = 0; var isLavaTransformed = false; var lavaTransformTimer = 0; var eggs = []; var totalEggs = 53; var eggTypes = ['egg1', 'egg2', 'egg3', 'egg4', 'egg5']; var playButton; var titleText; var titleBackground; var easterBunny; var lavaBunny; var shop; var scoreText; var remainingText; var shopBackground; var shopTitleText; var xButton; var upgradeButton1; var upgradeButton2; var upgradeText1; var upgradeText2; var eggCoinSprite1; var eggCoinSprite2; var eggCoinText1; var eggCoinText2; var eggCoins; var gameTimer; var gameTimeRemaining; var timerText; var clockSprite; // Title screen setup var titleBackground = LK.getAsset('titleBackground', { anchorX: 0.5, anchorY: 0.5 }); titleBackground.x = 2048 / 2; titleBackground.y = 600; game.addChild(titleBackground); titleText = new Text2('Easter Egg Hunt', { size: 120, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 600; game.addChild(titleText); easterBunny = LK.getAsset('easterBunny', { anchorX: 0.5, anchorY: 0.5 }); easterBunny.x = 2048 / 2; easterBunny.y = 1000; game.addChild(easterBunny); lavaBunny = LK.getAsset('lavaBunny', { anchorX: 0.5, anchorY: 0.5 }); lavaBunny.x = 2048 / 2; lavaBunny.y = 1000; lavaBunny.visible = false; game.addChild(lavaBunny); shop = LK.getAsset('shop', { anchorX: 0.5, anchorY: 0.5 }); shop.x = 2048 - 200; shop.y = 300; shop.down = function (x, y, obj) { if (gameState === 'title') { openShop(); } }; game.addChild(shop); playButton = game.addChild(new PlayButton()); playButton.x = 2048 / 2; playButton.y = 1400; // Blue box with "bunny run" text 2 steps under play button var bunnyRunBox = LK.getAsset('titleBackground', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 0.6 }); bunnyRunBox.x = 2048 / 2; bunnyRunBox.y = playButton.y + 242; // 2 steps (240px) under play button bunnyRunBox.tint = 0x0000ff; // Blue color game.addChild(bunnyRunBox); var bunnyRunText = new Text2('bunny run', { size: 60, fill: 0xFFFFFF }); bunnyRunText.anchor.set(0.5, 0.5); bunnyRunText.x = bunnyRunBox.x; bunnyRunText.y = bunnyRunBox.y; bunnyRunBox.down = function (x, y, obj) { startBunnyRun(); }; game.addChild(bunnyRunText); // High Score button - positioned below bunny run button var highScoreButton = game.addChild(new HighScoreButton()); highScoreButton.x = 2048 / 2; highScoreButton.y = bunnyRunBox.y + 180; // Below bunny run button // Red UI box container var uiBox = LK.getAsset('titleBackground', { anchorX: 0.5, anchorY: 0, scaleX: 2.5, scaleY: 0.8 }); uiBox.x = 2048 / 2; uiBox.y = 100; uiBox.visible = false; game.addChild(uiBox); // UI elements scoreText = new Text2('Score: 0', { size: 80, fill: 0xFFFFFF }); scoreText.anchor.set(0, 0); scoreText.x = 120; scoreText.y = 120; scoreText.visible = false; game.addChild(scoreText); remainingText = new Text2('Eggs Left: 0', { size: 80, fill: 0xFFFFFF }); remainingText.anchor.set(1, 0); remainingText.x = 2048 - 120; remainingText.y = 120; remainingText.visible = false; game.addChild(remainingText); timerText = new Text2('Time: 1:00', { size: 80, fill: 0xFFFFFF }); timerText.anchor.set(0.5, 0); timerText.x = 2048 / 2 + 162; timerText.y = 120; timerText.visible = false; game.addChild(timerText); clockSprite = LK.getAsset('clock', { anchorX: 0.5, anchorY: 0.5 }); clockSprite.x = 2048 / 2 - 160; clockSprite.y = 160; clockSprite.visible = false; game.addChild(clockSprite); // Shop screen setup shopBackground = LK.getAsset('titleBackground', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.5, scaleY: 4 }); shopBackground.x = 2048 / 2; shopBackground.y = 2732 / 2; shopBackground.visible = false; game.addChild(shopBackground); shopTitleText = new Text2('Bunny Upgrades', { size: 100, fill: 0xFFFFFF }); shopTitleText.anchor.set(0.5, 0.5); shopTitleText.x = 2048 / 2; shopTitleText.y = 800; shopTitleText.visible = false; game.addChild(shopTitleText); xButton = game.addChild(new XButton()); xButton.x = 2048 / 2 + 800; xButton.y = 400; xButton.visible = false; upgradeButton1 = LK.getAsset('playButton', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.2 }); upgradeButton1.x = 2048 / 2; upgradeButton1.y = 1200; upgradeButton1.visible = false; upgradeButton1.down = function (x, y, obj) { // Apply lava bunny skin if (eggCoins >= 5) { eggCoins -= 5; storage.eggCoins = eggCoins; storage.lavaBunnySkinApplied = true; easterBunny.visible = false; lavaBunny.visible = true; updateShopUI(); } }; game.addChild(upgradeButton1); upgradeText1 = new Text2('Lava Bunny Skin - 5 Egg Coins', { size: 50, fill: 0xFFFFFF }); upgradeText1.anchor.set(0.5, 0.5); upgradeText1.x = 2048 / 2; upgradeText1.y = 1200; upgradeText1.visible = false; game.addChild(upgradeText1); upgradeButton2 = LK.getAsset('playButton', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.2 }); upgradeButton2.x = 2048 / 2; upgradeButton2.y = 1500; upgradeButton2.visible = false; upgradeButton2.down = function (x, y, obj) { // Apply ninja bunny skin if (eggCoins >= 8) { eggCoins -= 8; storage.eggCoins = eggCoins; easterBunny.tint = 0x2c2c54; // Dark blue-gray ninja color updateShopUI(); } else { // Show insufficient funds message var insufficientText = new Text2('You dont have egg coins for this', { size: 40, fill: 0xFFFFFF }); insufficientText.anchor.set(0.5, 0.5); insufficientText.x = 2048 / 2; insufficientText.y = 1400; game.addChild(insufficientText); LK.setTimeout(function () { insufficientText.destroy(); }, 2000); } }; game.addChild(upgradeButton2); upgradeText2 = new Text2('Ninja Bunny Skin - 8 Egg Coins', { size: 50, fill: 0xFFFFFF }); upgradeText2.anchor.set(0.5, 0.5); upgradeText2.x = 2048 / 2; upgradeText2.y = 1500; upgradeText2.visible = false; game.addChild(upgradeText2); // Initialize egg coins from storage eggCoins = storage.eggCoins || 0; // Egg coin sprite and text for lava bunny upgrade eggCoinSprite1 = LK.getAsset('eggCoin', { anchorX: 0.5, anchorY: 0.5 }); eggCoinSprite1.x = 2048 / 2 - 200; eggCoinSprite1.y = 1200; eggCoinSprite1.visible = false; game.addChild(eggCoinSprite1); eggCoinText1 = new Text2('0', { size: 40, fill: 0xFFFFFF }); eggCoinText1.anchor.set(0.5, 0.5); eggCoinText1.x = 2048 / 2 - 130; eggCoinText1.y = 1200; eggCoinText1.visible = false; game.addChild(eggCoinText1); // Egg coin sprite and text for ninja bunny upgrade eggCoinSprite2 = LK.getAsset('eggCoin', { anchorX: 0.5, anchorY: 0.5 }); eggCoinSprite2.x = 2048 / 2 - 200; eggCoinSprite2.y = 1500; eggCoinSprite2.visible = false; game.addChild(eggCoinSprite2); eggCoinText2 = new Text2('0', { size: 40, fill: 0xFFFFFF }); eggCoinText2.anchor.set(0.5, 0.5); eggCoinText2.x = 2048 / 2 - 130; eggCoinText2.y = 1500; eggCoinText2.visible = false; game.addChild(eggCoinText2); function startGame() { gameState = 'playing'; // Hide title screen titleText.visible = false; titleBackground.visible = false; easterBunny.visible = false; lavaBunny.visible = false; playButton.visible = false; shop.visible = false; bunnyRunBox.visible = false; bunnyRunText.visible = false; highScoreButton.visible = false; highScoreButton.visible = false; // Show UI uiBox.visible = true; scoreText.visible = true; remainingText.visible = true; timerText.visible = true; clockSprite.visible = true; // Initialize 1 minute timer (60 seconds) gameTimeRemaining = 60; updateTimerDisplay(); gameTimer = LK.setInterval(function () { gameTimeRemaining--; updateTimerDisplay(); // Check if time is up if (gameTimeRemaining <= 0) { LK.clearInterval(gameTimer); // Player loses - show game over LK.setTimeout(function () { LK.showGameOver(); }, 100); } }, 1000); // Reset score LK.setScore(0); updateUI(); // Create eggs createEggs(); } function createEggs() { eggs = []; for (var i = 0; i < totalEggs; i++) { var eggType = eggTypes[Math.floor(Math.random() * eggTypes.length)]; var egg = new Egg(eggType); // Random position with margins to keep eggs fully visible egg.x = 150 + Math.random() * (2048 - 300); egg.y = 300 + Math.random() * (2732 - 600); // Ensure eggs don't overlap too much var attempts = 0; var tooClose = true; while (tooClose && attempts < 20) { tooClose = false; for (var j = 0; j < eggs.length; j++) { var distance = Math.sqrt(Math.pow(egg.x - eggs[j].x, 2) + Math.pow(egg.y - eggs[j].y, 2)); if (distance < 120) { tooClose = true; egg.x = 150 + Math.random() * (2048 - 300); egg.y = 300 + Math.random() * (2732 - 600); break; } } attempts++; } eggs.push(egg); game.addChild(egg); // Add a subtle spawn animation egg.alpha = 0; egg.scaleX = 0.5; egg.scaleY = 0.5; tween(egg, { alpha: 1, scaleX: 1, scaleY: 1 }, { duration: 300, easing: tween.easeOut }); } } function collectEgg(egg) { if (gameState !== 'playing') return; // Play collect sound LK.getSound('collect').play(); // Remove egg from array var index = eggs.indexOf(egg); if (index > -1) { eggs.splice(index, 1); } // Update score LK.setScore(LK.getScore() + 10); // Award egg coin eggCoins++; storage.eggCoins = eggCoins; // Animate egg collection tween(egg, { scaleX: 1.5, scaleY: 1.5, alpha: 0 }, { duration: 200, easing: tween.easeIn, onFinish: function onFinish() { egg.destroy(); } }); updateUI(); // Check win condition if (eggs.length === 0) { LK.clearInterval(gameTimer); // Save high score var currentScore = LK.getScore(); var highScore = storage.highScore || 0; if (currentScore > highScore) { storage.highScore = currentScore; } LK.setTimeout(function () { LK.showYouWin(); }, 500); } } function updateUI() { scoreText.setText('Score: ' + LK.getScore()); remainingText.setText('Eggs Left: ' + eggs.length); } function updateShopUI() { eggCoinText1.setText(eggCoins.toString()); eggCoinText2.setText(eggCoins.toString()); } function updateTimerDisplay() { var minutes = Math.floor(gameTimeRemaining / 60); var seconds = gameTimeRemaining % 60; var timeString = minutes + ':' + (seconds < 10 ? '0' : '') + seconds; timerText.setText('Time: ' + timeString); } function openShop() { gameState = 'shop'; // Hide title screen titleText.visible = false; titleBackground.visible = false; easterBunny.visible = false; lavaBunny.visible = false; playButton.visible = false; shop.visible = false; timerText.visible = false; uiBox.visible = false; clockSprite.visible = false; // Show shop screen shopBackground.visible = true; shopTitleText.visible = true; xButton.visible = true; upgradeButton1.visible = true; upgradeText1.visible = true; upgradeButton2.visible = true; upgradeText2.visible = true; eggCoinSprite1.visible = false; eggCoinText1.visible = false; eggCoinSprite2.visible = false; eggCoinText2.visible = false; updateShopUI(); } function showHighScores() { // Get high score from storage var highScore = storage.highScore || 0; // Create black box for high score display var highScoreBackground = LK.getAsset('titleBackground', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.0, scaleY: 2.0 }); highScoreBackground.x = 2048 / 2; highScoreBackground.y = 2732 / 2; highScoreBackground.tint = 0x000000; // Black background game.addChild(highScoreBackground); // Create black box for high score title var highScoreTitleBackground = LK.getAsset('titleBackground', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 0.8 }); highScoreTitleBackground.x = 2048 / 2; highScoreTitleBackground.y = 2732 / 2 - 200; highScoreTitleBackground.tint = 0x000000; // Black background game.addChild(highScoreTitleBackground); // Create high score title var highScoreTitleText = new Text2('HIGH SCORES', { size: 100, fill: 0xFFFFFF }); highScoreTitleText.anchor.set(0.5, 0.5); highScoreTitleText.x = 2048 / 2; highScoreTitleText.y = 2732 / 2 - 200; game.addChild(highScoreTitleText); // Create high score value display var highScoreValueText = new Text2('Best Score: ' + highScore, { size: 80, fill: 0xFFD700 }); highScoreValueText.anchor.set(0.5, 0.5); highScoreValueText.x = 2048 / 2; highScoreValueText.y = 2732 / 2; game.addChild(highScoreValueText); // Create close button var closeButton = LK.getAsset('playButton', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8 }); closeButton.x = 2048 / 2; closeButton.y = 2732 / 2 + 200; game.addChild(closeButton); var closeButtonText = new Text2('CLOSE', { size: 60, fill: 0xFFFFFF }); closeButtonText.anchor.set(0.5, 0.5); closeButtonText.x = closeButton.x; closeButtonText.y = closeButton.y; game.addChild(closeButtonText); // Add close functionality closeButton.down = function (x, y, obj) { highScoreBackground.destroy(); highScoreTitleBackground.destroy(); highScoreTitleText.destroy(); highScoreValueText.destroy(); closeButton.destroy(); closeButtonText.destroy(); }; } function closeShop() { gameState = 'title'; // Hide shop screen shopBackground.visible = false; shopTitleText.visible = false; xButton.visible = false; upgradeButton1.visible = false; upgradeText1.visible = false; upgradeButton2.visible = false; upgradeText2.visible = false; eggCoinSprite1.visible = false; eggCoinText1.visible = false; eggCoinSprite2.visible = false; eggCoinText2.visible = false; // Show title screen titleText.visible = true; titleBackground.visible = true; if (storage.lavaBunnySkinApplied) { lavaBunny.visible = true; easterBunny.visible = false; } else { easterBunny.visible = true; lavaBunny.visible = false; } playButton.visible = true; shop.visible = true; highScoreButton.visible = true; if (gameState === 'playing') { timerText.visible = true; uiBox.visible = true; clockSprite.visible = true; } } function startBunnyRun() { gameState = 'bunnyrun'; bunnyRunScore = 0; // Hide title screen titleText.visible = false; titleBackground.visible = false; easterBunny.visible = false; lavaBunny.visible = false; playButton.visible = false; shop.visible = false; highScoreButton.visible = false; bunnyRunBox.visible = false; bunnyRunText.visible = false; // Create ground var ground = LK.getAsset('ground', { anchorX: 0, anchorY: 1.0 }); ground.x = 0; ground.y = 2732; game.addChild(ground); // Create player bunnyRunPlayer = new BunnyRunPlayer(); bunnyRunPlayer.x = 300; bunnyRunPlayer.y = 2400; game.addChild(bunnyRunPlayer); // Clear obstacles array obstacles = []; // Clear power-ups array powerUps = []; // Reset transformation state isLavaTransformed = false; lavaTransformTimer = 0; // Show bunny run UI var bunnyRunScoreText = new Text2('Score: 0', { size: 80, fill: 0x000000 }); bunnyRunScoreText.anchor.set(0, 0); bunnyRunScoreText.x = 120; bunnyRunScoreText.y = 120; game.addChild(bunnyRunScoreText); } game.down = function (x, y, obj) { if (gameState === 'bunnyrun' && bunnyRunPlayer) { bunnyRunPlayer.jump(); } }; game.update = function () { if (gameState === 'bunnyrun') { // Update player if (bunnyRunPlayer) { bunnyRunPlayer.update(); } // Handle lava transformation timer if (isLavaTransformed) { lavaTransformTimer--; if (lavaTransformTimer <= 0) { isLavaTransformed = false; bunnyRunPlayer.transformToNormal(); } } // Spawn obstacles if (LK.ticks % 120 === 0) { var obstacle = new Obstacle(); obstacle.x = 2200; obstacle.y = 2400; obstacles.push(obstacle); game.addChild(obstacle); } // Spawn power-ups occasionally if (LK.ticks % 300 === 0 && Math.random() < 0.3) { var powerUp = new PowerUp(); powerUp.x = 2200; powerUp.y = 2200; powerUps.push(powerUp); game.addChild(powerUp); } // Update obstacles for (var i = obstacles.length - 1; i >= 0; i--) { var obstacle = obstacles[i]; obstacle.update(); // Check collision with player (only if not lava transformed) if (bunnyRunPlayer && obstacle.intersects(bunnyRunPlayer) && !isLavaTransformed) { // Save high score for bunny run var highScore = storage.highScore || 0; if (bunnyRunScore > highScore) { storage.highScore = bunnyRunScore; } // Game over LK.setTimeout(function () { LK.showGameOver(); }, 100); return; } // Remove obstacles that are off screen if (obstacle.x < -100) { obstacle.destroy(); obstacles.splice(i, 1); bunnyRunScore += 10; } } // Update power-ups for (var j = powerUps.length - 1; j >= 0; j--) { var powerUp = powerUps[j]; powerUp.update(); // Check collision with player if (bunnyRunPlayer && powerUp.intersects(bunnyRunPlayer)) { // Activate lava transformation isLavaTransformed = true; lavaTransformTimer = 300; // 5 seconds at 60fps bunnyRunPlayer.transformToLava(); // Remove power-up powerUp.destroy(); powerUps.splice(j, 1); continue; } // Remove power-ups that are off screen if (powerUp.x < -100) { powerUp.destroy(); powerUps.splice(j, 1); } } } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var BunnyRunPlayer = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('easterBunny', {
anchorX: 0.5,
anchorY: 1.0,
scaleX: 0.5,
scaleY: 0.5
});
var lavaGraphics = self.attachAsset('lavaBunny', {
anchorX: 0.5,
anchorY: 1.0,
scaleX: 0.5,
scaleY: 0.5
});
lavaGraphics.visible = false;
self.isJumping = false;
self.jumpSpeed = 0;
self.gravity = 1;
self.groundY = 2400;
self.transformToLava = function () {
playerGraphics.visible = false;
lavaGraphics.visible = true;
tween(self, {
tint: 0xff4444
}, {
duration: 300,
easing: tween.easeOut
});
};
self.transformToNormal = function () {
playerGraphics.visible = true;
lavaGraphics.visible = false;
tween(self, {
tint: 0xffffff
}, {
duration: 300,
easing: tween.easeOut
});
};
self.update = function () {
if (self.isJumping) {
self.y += self.jumpSpeed;
self.jumpSpeed += self.gravity;
if (self.y >= self.groundY) {
self.y = self.groundY;
self.isJumping = false;
self.jumpSpeed = 0;
}
}
};
self.jump = function () {
if (!self.isJumping) {
self.isJumping = true;
self.jumpSpeed = -35;
}
};
return self;
});
var Egg = Container.expand(function (eggType) {
var self = Container.call(this);
var eggGraphics = self.attachAsset(eggType, {
anchorX: 0.5,
anchorY: 0.5
});
self.down = function (x, y, obj) {
collectEgg(self);
};
return self;
});
var HighScoreButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('highScoreButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2('HIGH SCORES', {
size: 50,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function (x, y, obj) {
showHighScores();
};
return self;
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 1.0
});
self.update = function () {
self.x -= obstacleSpeed;
};
return self;
});
var PlayButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('playButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2('PLAY', {
size: 60,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function (x, y, obj) {
startGame();
};
return self;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('powerUpSprite', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.x -= obstacleSpeed;
};
return self;
});
var XButton = Container.expand(function () {
var self = Container.call(this);
var buttonBackground = self.attachAsset('xButtonBackground', {
anchorX: 0.5,
anchorY: 0.5
});
var xText = new Text2('X', {
size: 80,
fill: 0xFFFFFF
});
xText.anchor.set(0.5, 0.5);
self.addChild(xText);
self.down = function (x, y, obj) {
closeShop();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x00ff00
});
/****
* Game Code
****/
var gameState = 'title'; // 'title', 'playing', 'shop', or 'bunnyrun'
var bunnyRunPlayer;
var obstacles = [];
var powerUps = [];
var bunnyRunSpeed = 5;
var obstacleSpeed = 8;
var bunnyRunScore = 0;
var isLavaTransformed = false;
var lavaTransformTimer = 0;
var eggs = [];
var totalEggs = 53;
var eggTypes = ['egg1', 'egg2', 'egg3', 'egg4', 'egg5'];
var playButton;
var titleText;
var titleBackground;
var easterBunny;
var lavaBunny;
var shop;
var scoreText;
var remainingText;
var shopBackground;
var shopTitleText;
var xButton;
var upgradeButton1;
var upgradeButton2;
var upgradeText1;
var upgradeText2;
var eggCoinSprite1;
var eggCoinSprite2;
var eggCoinText1;
var eggCoinText2;
var eggCoins;
var gameTimer;
var gameTimeRemaining;
var timerText;
var clockSprite;
// Title screen setup
var titleBackground = LK.getAsset('titleBackground', {
anchorX: 0.5,
anchorY: 0.5
});
titleBackground.x = 2048 / 2;
titleBackground.y = 600;
game.addChild(titleBackground);
titleText = new Text2('Easter Egg Hunt', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 600;
game.addChild(titleText);
easterBunny = LK.getAsset('easterBunny', {
anchorX: 0.5,
anchorY: 0.5
});
easterBunny.x = 2048 / 2;
easterBunny.y = 1000;
game.addChild(easterBunny);
lavaBunny = LK.getAsset('lavaBunny', {
anchorX: 0.5,
anchorY: 0.5
});
lavaBunny.x = 2048 / 2;
lavaBunny.y = 1000;
lavaBunny.visible = false;
game.addChild(lavaBunny);
shop = LK.getAsset('shop', {
anchorX: 0.5,
anchorY: 0.5
});
shop.x = 2048 - 200;
shop.y = 300;
shop.down = function (x, y, obj) {
if (gameState === 'title') {
openShop();
}
};
game.addChild(shop);
playButton = game.addChild(new PlayButton());
playButton.x = 2048 / 2;
playButton.y = 1400;
// Blue box with "bunny run" text 2 steps under play button
var bunnyRunBox = LK.getAsset('titleBackground', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 0.6
});
bunnyRunBox.x = 2048 / 2;
bunnyRunBox.y = playButton.y + 242; // 2 steps (240px) under play button
bunnyRunBox.tint = 0x0000ff; // Blue color
game.addChild(bunnyRunBox);
var bunnyRunText = new Text2('bunny run', {
size: 60,
fill: 0xFFFFFF
});
bunnyRunText.anchor.set(0.5, 0.5);
bunnyRunText.x = bunnyRunBox.x;
bunnyRunText.y = bunnyRunBox.y;
bunnyRunBox.down = function (x, y, obj) {
startBunnyRun();
};
game.addChild(bunnyRunText);
// High Score button - positioned below bunny run button
var highScoreButton = game.addChild(new HighScoreButton());
highScoreButton.x = 2048 / 2;
highScoreButton.y = bunnyRunBox.y + 180; // Below bunny run button
// Red UI box container
var uiBox = LK.getAsset('titleBackground', {
anchorX: 0.5,
anchorY: 0,
scaleX: 2.5,
scaleY: 0.8
});
uiBox.x = 2048 / 2;
uiBox.y = 100;
uiBox.visible = false;
game.addChild(uiBox);
// UI elements
scoreText = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreText.anchor.set(0, 0);
scoreText.x = 120;
scoreText.y = 120;
scoreText.visible = false;
game.addChild(scoreText);
remainingText = new Text2('Eggs Left: 0', {
size: 80,
fill: 0xFFFFFF
});
remainingText.anchor.set(1, 0);
remainingText.x = 2048 - 120;
remainingText.y = 120;
remainingText.visible = false;
game.addChild(remainingText);
timerText = new Text2('Time: 1:00', {
size: 80,
fill: 0xFFFFFF
});
timerText.anchor.set(0.5, 0);
timerText.x = 2048 / 2 + 162;
timerText.y = 120;
timerText.visible = false;
game.addChild(timerText);
clockSprite = LK.getAsset('clock', {
anchorX: 0.5,
anchorY: 0.5
});
clockSprite.x = 2048 / 2 - 160;
clockSprite.y = 160;
clockSprite.visible = false;
game.addChild(clockSprite);
// Shop screen setup
shopBackground = LK.getAsset('titleBackground', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.5,
scaleY: 4
});
shopBackground.x = 2048 / 2;
shopBackground.y = 2732 / 2;
shopBackground.visible = false;
game.addChild(shopBackground);
shopTitleText = new Text2('Bunny Upgrades', {
size: 100,
fill: 0xFFFFFF
});
shopTitleText.anchor.set(0.5, 0.5);
shopTitleText.x = 2048 / 2;
shopTitleText.y = 800;
shopTitleText.visible = false;
game.addChild(shopTitleText);
xButton = game.addChild(new XButton());
xButton.x = 2048 / 2 + 800;
xButton.y = 400;
xButton.visible = false;
upgradeButton1 = LK.getAsset('playButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2
});
upgradeButton1.x = 2048 / 2;
upgradeButton1.y = 1200;
upgradeButton1.visible = false;
upgradeButton1.down = function (x, y, obj) {
// Apply lava bunny skin
if (eggCoins >= 5) {
eggCoins -= 5;
storage.eggCoins = eggCoins;
storage.lavaBunnySkinApplied = true;
easterBunny.visible = false;
lavaBunny.visible = true;
updateShopUI();
}
};
game.addChild(upgradeButton1);
upgradeText1 = new Text2('Lava Bunny Skin - 5 Egg Coins', {
size: 50,
fill: 0xFFFFFF
});
upgradeText1.anchor.set(0.5, 0.5);
upgradeText1.x = 2048 / 2;
upgradeText1.y = 1200;
upgradeText1.visible = false;
game.addChild(upgradeText1);
upgradeButton2 = LK.getAsset('playButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2
});
upgradeButton2.x = 2048 / 2;
upgradeButton2.y = 1500;
upgradeButton2.visible = false;
upgradeButton2.down = function (x, y, obj) {
// Apply ninja bunny skin
if (eggCoins >= 8) {
eggCoins -= 8;
storage.eggCoins = eggCoins;
easterBunny.tint = 0x2c2c54; // Dark blue-gray ninja color
updateShopUI();
} else {
// Show insufficient funds message
var insufficientText = new Text2('You dont have egg coins for this', {
size: 40,
fill: 0xFFFFFF
});
insufficientText.anchor.set(0.5, 0.5);
insufficientText.x = 2048 / 2;
insufficientText.y = 1400;
game.addChild(insufficientText);
LK.setTimeout(function () {
insufficientText.destroy();
}, 2000);
}
};
game.addChild(upgradeButton2);
upgradeText2 = new Text2('Ninja Bunny Skin - 8 Egg Coins', {
size: 50,
fill: 0xFFFFFF
});
upgradeText2.anchor.set(0.5, 0.5);
upgradeText2.x = 2048 / 2;
upgradeText2.y = 1500;
upgradeText2.visible = false;
game.addChild(upgradeText2);
// Initialize egg coins from storage
eggCoins = storage.eggCoins || 0;
// Egg coin sprite and text for lava bunny upgrade
eggCoinSprite1 = LK.getAsset('eggCoin', {
anchorX: 0.5,
anchorY: 0.5
});
eggCoinSprite1.x = 2048 / 2 - 200;
eggCoinSprite1.y = 1200;
eggCoinSprite1.visible = false;
game.addChild(eggCoinSprite1);
eggCoinText1 = new Text2('0', {
size: 40,
fill: 0xFFFFFF
});
eggCoinText1.anchor.set(0.5, 0.5);
eggCoinText1.x = 2048 / 2 - 130;
eggCoinText1.y = 1200;
eggCoinText1.visible = false;
game.addChild(eggCoinText1);
// Egg coin sprite and text for ninja bunny upgrade
eggCoinSprite2 = LK.getAsset('eggCoin', {
anchorX: 0.5,
anchorY: 0.5
});
eggCoinSprite2.x = 2048 / 2 - 200;
eggCoinSprite2.y = 1500;
eggCoinSprite2.visible = false;
game.addChild(eggCoinSprite2);
eggCoinText2 = new Text2('0', {
size: 40,
fill: 0xFFFFFF
});
eggCoinText2.anchor.set(0.5, 0.5);
eggCoinText2.x = 2048 / 2 - 130;
eggCoinText2.y = 1500;
eggCoinText2.visible = false;
game.addChild(eggCoinText2);
function startGame() {
gameState = 'playing';
// Hide title screen
titleText.visible = false;
titleBackground.visible = false;
easterBunny.visible = false;
lavaBunny.visible = false;
playButton.visible = false;
shop.visible = false;
bunnyRunBox.visible = false;
bunnyRunText.visible = false;
highScoreButton.visible = false;
highScoreButton.visible = false;
// Show UI
uiBox.visible = true;
scoreText.visible = true;
remainingText.visible = true;
timerText.visible = true;
clockSprite.visible = true;
// Initialize 1 minute timer (60 seconds)
gameTimeRemaining = 60;
updateTimerDisplay();
gameTimer = LK.setInterval(function () {
gameTimeRemaining--;
updateTimerDisplay();
// Check if time is up
if (gameTimeRemaining <= 0) {
LK.clearInterval(gameTimer);
// Player loses - show game over
LK.setTimeout(function () {
LK.showGameOver();
}, 100);
}
}, 1000);
// Reset score
LK.setScore(0);
updateUI();
// Create eggs
createEggs();
}
function createEggs() {
eggs = [];
for (var i = 0; i < totalEggs; i++) {
var eggType = eggTypes[Math.floor(Math.random() * eggTypes.length)];
var egg = new Egg(eggType);
// Random position with margins to keep eggs fully visible
egg.x = 150 + Math.random() * (2048 - 300);
egg.y = 300 + Math.random() * (2732 - 600);
// Ensure eggs don't overlap too much
var attempts = 0;
var tooClose = true;
while (tooClose && attempts < 20) {
tooClose = false;
for (var j = 0; j < eggs.length; j++) {
var distance = Math.sqrt(Math.pow(egg.x - eggs[j].x, 2) + Math.pow(egg.y - eggs[j].y, 2));
if (distance < 120) {
tooClose = true;
egg.x = 150 + Math.random() * (2048 - 300);
egg.y = 300 + Math.random() * (2732 - 600);
break;
}
}
attempts++;
}
eggs.push(egg);
game.addChild(egg);
// Add a subtle spawn animation
egg.alpha = 0;
egg.scaleX = 0.5;
egg.scaleY = 0.5;
tween(egg, {
alpha: 1,
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.easeOut
});
}
}
function collectEgg(egg) {
if (gameState !== 'playing') return;
// Play collect sound
LK.getSound('collect').play();
// Remove egg from array
var index = eggs.indexOf(egg);
if (index > -1) {
eggs.splice(index, 1);
}
// Update score
LK.setScore(LK.getScore() + 10);
// Award egg coin
eggCoins++;
storage.eggCoins = eggCoins;
// Animate egg collection
tween(egg, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 200,
easing: tween.easeIn,
onFinish: function onFinish() {
egg.destroy();
}
});
updateUI();
// Check win condition
if (eggs.length === 0) {
LK.clearInterval(gameTimer);
// Save high score
var currentScore = LK.getScore();
var highScore = storage.highScore || 0;
if (currentScore > highScore) {
storage.highScore = currentScore;
}
LK.setTimeout(function () {
LK.showYouWin();
}, 500);
}
}
function updateUI() {
scoreText.setText('Score: ' + LK.getScore());
remainingText.setText('Eggs Left: ' + eggs.length);
}
function updateShopUI() {
eggCoinText1.setText(eggCoins.toString());
eggCoinText2.setText(eggCoins.toString());
}
function updateTimerDisplay() {
var minutes = Math.floor(gameTimeRemaining / 60);
var seconds = gameTimeRemaining % 60;
var timeString = minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
timerText.setText('Time: ' + timeString);
}
function openShop() {
gameState = 'shop';
// Hide title screen
titleText.visible = false;
titleBackground.visible = false;
easterBunny.visible = false;
lavaBunny.visible = false;
playButton.visible = false;
shop.visible = false;
timerText.visible = false;
uiBox.visible = false;
clockSprite.visible = false;
// Show shop screen
shopBackground.visible = true;
shopTitleText.visible = true;
xButton.visible = true;
upgradeButton1.visible = true;
upgradeText1.visible = true;
upgradeButton2.visible = true;
upgradeText2.visible = true;
eggCoinSprite1.visible = false;
eggCoinText1.visible = false;
eggCoinSprite2.visible = false;
eggCoinText2.visible = false;
updateShopUI();
}
function showHighScores() {
// Get high score from storage
var highScore = storage.highScore || 0;
// Create black box for high score display
var highScoreBackground = LK.getAsset('titleBackground', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.0,
scaleY: 2.0
});
highScoreBackground.x = 2048 / 2;
highScoreBackground.y = 2732 / 2;
highScoreBackground.tint = 0x000000; // Black background
game.addChild(highScoreBackground);
// Create black box for high score title
var highScoreTitleBackground = LK.getAsset('titleBackground', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 0.8
});
highScoreTitleBackground.x = 2048 / 2;
highScoreTitleBackground.y = 2732 / 2 - 200;
highScoreTitleBackground.tint = 0x000000; // Black background
game.addChild(highScoreTitleBackground);
// Create high score title
var highScoreTitleText = new Text2('HIGH SCORES', {
size: 100,
fill: 0xFFFFFF
});
highScoreTitleText.anchor.set(0.5, 0.5);
highScoreTitleText.x = 2048 / 2;
highScoreTitleText.y = 2732 / 2 - 200;
game.addChild(highScoreTitleText);
// Create high score value display
var highScoreValueText = new Text2('Best Score: ' + highScore, {
size: 80,
fill: 0xFFD700
});
highScoreValueText.anchor.set(0.5, 0.5);
highScoreValueText.x = 2048 / 2;
highScoreValueText.y = 2732 / 2;
game.addChild(highScoreValueText);
// Create close button
var closeButton = LK.getAsset('playButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8
});
closeButton.x = 2048 / 2;
closeButton.y = 2732 / 2 + 200;
game.addChild(closeButton);
var closeButtonText = new Text2('CLOSE', {
size: 60,
fill: 0xFFFFFF
});
closeButtonText.anchor.set(0.5, 0.5);
closeButtonText.x = closeButton.x;
closeButtonText.y = closeButton.y;
game.addChild(closeButtonText);
// Add close functionality
closeButton.down = function (x, y, obj) {
highScoreBackground.destroy();
highScoreTitleBackground.destroy();
highScoreTitleText.destroy();
highScoreValueText.destroy();
closeButton.destroy();
closeButtonText.destroy();
};
}
function closeShop() {
gameState = 'title';
// Hide shop screen
shopBackground.visible = false;
shopTitleText.visible = false;
xButton.visible = false;
upgradeButton1.visible = false;
upgradeText1.visible = false;
upgradeButton2.visible = false;
upgradeText2.visible = false;
eggCoinSprite1.visible = false;
eggCoinText1.visible = false;
eggCoinSprite2.visible = false;
eggCoinText2.visible = false;
// Show title screen
titleText.visible = true;
titleBackground.visible = true;
if (storage.lavaBunnySkinApplied) {
lavaBunny.visible = true;
easterBunny.visible = false;
} else {
easterBunny.visible = true;
lavaBunny.visible = false;
}
playButton.visible = true;
shop.visible = true;
highScoreButton.visible = true;
if (gameState === 'playing') {
timerText.visible = true;
uiBox.visible = true;
clockSprite.visible = true;
}
}
function startBunnyRun() {
gameState = 'bunnyrun';
bunnyRunScore = 0;
// Hide title screen
titleText.visible = false;
titleBackground.visible = false;
easterBunny.visible = false;
lavaBunny.visible = false;
playButton.visible = false;
shop.visible = false;
highScoreButton.visible = false;
bunnyRunBox.visible = false;
bunnyRunText.visible = false;
// Create ground
var ground = LK.getAsset('ground', {
anchorX: 0,
anchorY: 1.0
});
ground.x = 0;
ground.y = 2732;
game.addChild(ground);
// Create player
bunnyRunPlayer = new BunnyRunPlayer();
bunnyRunPlayer.x = 300;
bunnyRunPlayer.y = 2400;
game.addChild(bunnyRunPlayer);
// Clear obstacles array
obstacles = [];
// Clear power-ups array
powerUps = [];
// Reset transformation state
isLavaTransformed = false;
lavaTransformTimer = 0;
// Show bunny run UI
var bunnyRunScoreText = new Text2('Score: 0', {
size: 80,
fill: 0x000000
});
bunnyRunScoreText.anchor.set(0, 0);
bunnyRunScoreText.x = 120;
bunnyRunScoreText.y = 120;
game.addChild(bunnyRunScoreText);
}
game.down = function (x, y, obj) {
if (gameState === 'bunnyrun' && bunnyRunPlayer) {
bunnyRunPlayer.jump();
}
};
game.update = function () {
if (gameState === 'bunnyrun') {
// Update player
if (bunnyRunPlayer) {
bunnyRunPlayer.update();
}
// Handle lava transformation timer
if (isLavaTransformed) {
lavaTransformTimer--;
if (lavaTransformTimer <= 0) {
isLavaTransformed = false;
bunnyRunPlayer.transformToNormal();
}
}
// Spawn obstacles
if (LK.ticks % 120 === 0) {
var obstacle = new Obstacle();
obstacle.x = 2200;
obstacle.y = 2400;
obstacles.push(obstacle);
game.addChild(obstacle);
}
// Spawn power-ups occasionally
if (LK.ticks % 300 === 0 && Math.random() < 0.3) {
var powerUp = new PowerUp();
powerUp.x = 2200;
powerUp.y = 2200;
powerUps.push(powerUp);
game.addChild(powerUp);
}
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
obstacle.update();
// Check collision with player (only if not lava transformed)
if (bunnyRunPlayer && obstacle.intersects(bunnyRunPlayer) && !isLavaTransformed) {
// Save high score for bunny run
var highScore = storage.highScore || 0;
if (bunnyRunScore > highScore) {
storage.highScore = bunnyRunScore;
}
// Game over
LK.setTimeout(function () {
LK.showGameOver();
}, 100);
return;
}
// Remove obstacles that are off screen
if (obstacle.x < -100) {
obstacle.destroy();
obstacles.splice(i, 1);
bunnyRunScore += 10;
}
}
// Update power-ups
for (var j = powerUps.length - 1; j >= 0; j--) {
var powerUp = powerUps[j];
powerUp.update();
// Check collision with player
if (bunnyRunPlayer && powerUp.intersects(bunnyRunPlayer)) {
// Activate lava transformation
isLavaTransformed = true;
lavaTransformTimer = 300; // 5 seconds at 60fps
bunnyRunPlayer.transformToLava();
// Remove power-up
powerUp.destroy();
powerUps.splice(j, 1);
continue;
}
// Remove power-ups that are off screen
if (powerUp.x < -100) {
powerUp.destroy();
powerUps.splice(j, 1);
}
}
}
};
RED EGG. In-Game asset. 2d. High contrast. No shadows
BLUE EGG. In-Game asset. 2d. High contrast. No shadows
YELLOW EGG. In-Game asset. 2d. High contrast. No shadows
PINK EGG. In-Game asset. 2d. High contrast. No shadows
CYAN EGG. In-Game asset. 2d. High contrast. No shadows
EASTER BUNNY. In-Game asset. 2d. High contrast. No shadows
SHOP. In-Game asset. 2d. High contrast. No shadows
LAVA BUNNY. In-Game asset. 2d. High contrast. No shadows
CLOCK. In-Game asset. 2d. High contrast. No shadows
traffic cone. In-Game asset. 2d. High contrast. No shadows
power up. In-Game asset. 2d. High contrast. No shadows