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"); /**** * Classes ****/ 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 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 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', or 'shop' var eggs = []; var totalEggs = 12; var eggTypes = ['egg1', 'egg2', 'egg3', 'egg4', 'egg5']; var playButton; var titleText; var titleBackground; var easterBunny; var shop; var scoreText; var remainingText; var shopBackground; var shopTitleText; var xButton; var upgradeButton1; var upgradeButton2; var upgradeText1; var upgradeText2; // 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); 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; // 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); // 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) { // Upgrade bunny speed }; game.addChild(upgradeButton1); upgradeText1 = new Text2('Speed Boost - 100 pts', { 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) { // Upgrade bunny size }; game.addChild(upgradeButton2); upgradeText2 = new Text2('Size Boost - 150 pts', { size: 50, fill: 0xFFFFFF }); upgradeText2.anchor.set(0.5, 0.5); upgradeText2.x = 2048 / 2; upgradeText2.y = 1500; upgradeText2.visible = false; game.addChild(upgradeText2); function startGame() { gameState = 'playing'; // Hide title screen titleText.visible = false; titleBackground.visible = false; easterBunny.visible = false; playButton.visible = false; shop.visible = false; // Show UI scoreText.visible = true; remainingText.visible = true; // 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); // 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.setTimeout(function () { LK.showYouWin(); }, 500); } } function updateUI() { scoreText.setText('Score: ' + LK.getScore()); remainingText.setText('Eggs Left: ' + eggs.length); } function openShop() { gameState = 'shop'; // Hide title screen titleText.visible = false; titleBackground.visible = false; easterBunny.visible = false; playButton.visible = false; shop.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; } 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; // Show title screen titleText.visible = true; titleBackground.visible = true; easterBunny.visible = true; playButton.visible = true; shop.visible = true; } game.update = function () { // Game logic handled by events and functions };
===================================================================
--- original.js
+++ change.js
@@ -33,8 +33,25 @@
startGame();
};
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
****/
@@ -44,9 +61,9 @@
/****
* Game Code
****/
-var gameState = 'title'; // 'title' or 'playing'
+var gameState = 'title'; // 'title', 'playing', or 'shop'
var eggs = [];
var totalEggs = 12;
var eggTypes = ['egg1', 'egg2', 'egg3', 'egg4', 'egg5'];
var playButton;
@@ -55,8 +72,15 @@
var easterBunny;
var shop;
var scoreText;
var remainingText;
+var shopBackground;
+var shopTitleText;
+var xButton;
+var upgradeButton1;
+var upgradeButton2;
+var upgradeText1;
+var upgradeText2;
// Title screen setup
var titleBackground = LK.getAsset('titleBackground', {
anchorX: 0.5,
anchorY: 0.5
@@ -84,8 +108,13 @@
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;
@@ -107,8 +136,74 @@
remainingText.x = 2048 - 120;
remainingText.y = 120;
remainingText.visible = false;
game.addChild(remainingText);
+// 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) {
+ // Upgrade bunny speed
+};
+game.addChild(upgradeButton1);
+upgradeText1 = new Text2('Speed Boost - 100 pts', {
+ 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) {
+ // Upgrade bunny size
+};
+game.addChild(upgradeButton2);
+upgradeText2 = new Text2('Size Boost - 150 pts', {
+ size: 50,
+ fill: 0xFFFFFF
+});
+upgradeText2.anchor.set(0.5, 0.5);
+upgradeText2.x = 2048 / 2;
+upgradeText2.y = 1500;
+upgradeText2.visible = false;
+game.addChild(upgradeText2);
function startGame() {
gameState = 'playing';
// Hide title screen
titleText.visible = false;
@@ -199,7 +294,41 @@
function updateUI() {
scoreText.setText('Score: ' + LK.getScore());
remainingText.setText('Eggs Left: ' + eggs.length);
}
+function openShop() {
+ gameState = 'shop';
+ // Hide title screen
+ titleText.visible = false;
+ titleBackground.visible = false;
+ easterBunny.visible = false;
+ playButton.visible = false;
+ shop.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;
+}
+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;
+ // Show title screen
+ titleText.visible = true;
+ titleBackground.visible = true;
+ easterBunny.visible = true;
+ playButton.visible = true;
+ shop.visible = true;
+}
game.update = function () {
// Game logic handled by events and functions
};
\ No newline at end of file
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