User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'y')' in or related to this line: 'if (protectionTimer > 0) {' Line Number: 176
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'y')' in or related to this line: 'if (protectionTimer > 0) {' Line Number: 176
User prompt
Add a golden egg that grants the wolf protection from rotten eggs for 15 seconds
User prompt
remove bonus shield
User prompt
add bonus shield
User prompt
less rotten eggs
User prompt
different speed for eggs
User prompt
if you lose egg you lose one life
User prompt
move life counter some down
User prompt
move life counter to center
User prompt
replace life counter to the left
User prompt
add life counter
User prompt
add chicken coop at background
Initial prompt
EggKeeper
===================================================================
--- original.js
+++ change.js
@@ -1,54 +1,60 @@
-/****
+/****
* Classes
-****/
+****/
// Egg class for falling eggs
var Egg = Container.expand(function () {
- var self = Container.call(this);
- var eggGraphics = self.attachAsset('egg', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 5;
- self.update = function () {
- self.y += self.speed;
- };
+ var self = Container.call(this);
+ var eggGraphics = self.attachAsset('egg', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 5;
+ self.update = function () {
+ self.y += self.speed;
+ };
});
// RottenEgg class for falling rotten eggs
var RottenEgg = Container.expand(function () {
- var self = Container.call(this);
- var rottenEggGraphics = self.attachAsset('rottenEgg', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 5;
- self.update = function () {
- self.y += self.speed;
- };
+ var self = Container.call(this);
+ var rottenEggGraphics = self.attachAsset('rottenEgg', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 5;
+ self.update = function () {
+ self.y += self.speed;
+ };
});
//<Assets used in the game will automatically appear here>
// Wolf class to control the player character
var Wolf = Container.expand(function () {
- var self = Container.call(this);
- var wolfGraphics = self.attachAsset('wolf', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.update = function () {
- // Wolf update logic if needed
- };
+ var self = Container.call(this);
+ var wolfGraphics = self.attachAsset('wolf', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ // Wolf update logic if needed
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x000000 //Init game with black background
});
-/****
+/****
* Game Code
-****/
+****/
+var background = game.attachAsset('background', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2
+});
// Initialize game variables
var wolf = game.addChild(new Wolf());
wolf.x = 2048 / 2;
wolf.y = 2732 - 200;
@@ -57,68 +63,68 @@
var score = 0;
var lives = 3;
// Display score
var scoreTxt = new Text2('Score: 0', {
- size: 100,
- fill: "#ffffff"
+ size: 100,
+ fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Display lives
var livesTxt = new Text2('Lives: 3', {
- size: 100,
- fill: "#ffffff"
+ size: 100,
+ fill: "#ffffff"
});
livesTxt.anchor.set(0.5, 0);
LK.gui.topRight.addChild(livesTxt);
// Handle wolf movement
game.move = function (x, y, obj) {
- wolf.x = x;
+ wolf.x = x;
};
// Update game state
game.update = function () {
- // Spawn eggs and rotten eggs
- if (LK.ticks % 60 == 0) {
- var newEgg = new Egg();
- newEgg.x = Math.random() * 2048;
- newEgg.y = -50;
- eggs.push(newEgg);
- game.addChild(newEgg);
- }
- if (LK.ticks % 120 == 0) {
- var newRottenEgg = new RottenEgg();
- newRottenEgg.x = Math.random() * 2048;
- newRottenEgg.y = -50;
- rottenEggs.push(newRottenEgg);
- game.addChild(newRottenEgg);
- }
- // Update eggs and check for collisions
- for (var i = eggs.length - 1; i >= 0; i--) {
- eggs[i].update();
- if (eggs[i].intersects(wolf)) {
- score += 1;
- scoreTxt.setText('Score: ' + score);
- eggs[i].destroy();
- eggs.splice(i, 1);
- } else if (eggs[i].y > 2732) {
- eggs[i].destroy();
- eggs.splice(i, 1);
- }
- }
- // Update rotten eggs and check for collisions
- for (var i = rottenEggs.length - 1; i >= 0; i--) {
- rottenEggs[i].update();
- if (rottenEggs[i].intersects(wolf)) {
- lives -= 1;
- livesTxt.setText('Lives: ' + lives);
- rottenEggs[i].destroy();
- rottenEggs.splice(i, 1);
- if (lives <= 0) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- }
- } else if (rottenEggs[i].y > 2732) {
- rottenEggs[i].destroy();
- rottenEggs.splice(i, 1);
- }
- }
+ // Spawn eggs and rotten eggs
+ if (LK.ticks % 60 == 0) {
+ var newEgg = new Egg();
+ newEgg.x = Math.random() * 2048;
+ newEgg.y = -50;
+ eggs.push(newEgg);
+ game.addChild(newEgg);
+ }
+ if (LK.ticks % 120 == 0) {
+ var newRottenEgg = new RottenEgg();
+ newRottenEgg.x = Math.random() * 2048;
+ newRottenEgg.y = -50;
+ rottenEggs.push(newRottenEgg);
+ game.addChild(newRottenEgg);
+ }
+ // Update eggs and check for collisions
+ for (var i = eggs.length - 1; i >= 0; i--) {
+ eggs[i].update();
+ if (eggs[i].intersects(wolf)) {
+ score += 1;
+ scoreTxt.setText('Score: ' + score);
+ eggs[i].destroy();
+ eggs.splice(i, 1);
+ } else if (eggs[i].y > 2732) {
+ eggs[i].destroy();
+ eggs.splice(i, 1);
+ }
+ }
+ // Update rotten eggs and check for collisions
+ for (var i = rottenEggs.length - 1; i >= 0; i--) {
+ rottenEggs[i].update();
+ if (rottenEggs[i].intersects(wolf)) {
+ lives -= 1;
+ livesTxt.setText('Lives: ' + lives);
+ rottenEggs[i].destroy();
+ rottenEggs.splice(i, 1);
+ if (lives <= 0) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+ } else if (rottenEggs[i].y > 2732) {
+ rottenEggs[i].destroy();
+ rottenEggs.splice(i, 1);
+ }
+ }
};
\ No newline at end of file
Cartoon wolf. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cartoon egg. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cartoon rotten egg. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon golden egg. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon egg with big heart. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon scared chicken. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon bonus egg. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.