User prompt
slightly reduce the frequency of bad items
User prompt
show lifes based on how many lifes you have left
User prompt
give 3 lifes
User prompt
put life at the top right
User prompt
show lifes in the middle at the bottom instead
User prompt
Please fix the bug: 'ReferenceError: scoreTxt is not defined' in or related to this line: 'scoreTxt.setText(LK.getScore());' Line Number: 140
User prompt
show lifes at the top right
User prompt
swap the lives number with the life class, show the number of lives based on how many lives you have
User prompt
create life class and attach the asset
User prompt
put lives at the top right
User prompt
add 3 lives
User prompt
Please fix the bug: 'ReferenceError: bucketGraphics is not defined' in or related to this line: 'bucketGraphics.visible = false;' Line Number: 50
User prompt
Please fix the bug: 'ReferenceError: bucketGraphics is not defined' in or related to this line: 'bucketGraphics.visible = false;' Line Number: 49
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'visible')' in or related to this line: 'if (bucket.bucketGraphics.visible) {' Line Number: 117
User prompt
only increment points when the mouth is open, if the mouth is closed and you touch the food, game over
User prompt
Please fix the bug: 'ReferenceError: closedGraphics is not defined' in or related to this line: 'closedGraphics.visible = true;' Line Number: 45
User prompt
when the mouth is closed, hide the other one. WHen the mouth is open, hide the closed
User prompt
when no noise make the mouth closed, when volume and noise, make the mouth closed ↪💡 Consider importing and using the following plugins: @upit/facekit.v1
User prompt
Please fix the bug: 'TypeError: self.swapAsset is not a function' in or related to this line: 'self.swapAsset('bucket');' Line Number: 40
User prompt
make the mouth closed by default, when theres volume, swap to the bucket asset and make it open
User prompt
make the game over when a good falling object hits the bottom
User prompt
make bad items appear more frequently, every few seconds
User prompt
make the bad items game over when it touches the mouth as opposed to touching the bottom
User prompt
make bad items appear much rarer, once every 10-20 seconds sequentially
User prompt
add bad items that game over if they hit the bottom
/**** * Plugins ****/ var facekit = LK.import("@upit/facekit.v1"); /**** * Classes ****/ // Class for Bad Items var BadItem = Container.expand(function () { var self = Container.call(this); var badItemGraphics = self.attachAsset('badItem', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.update = function () { self.y += self.speed; }; }); // Class for the Bucket (Player) var Bucket = Container.expand(function () { var self = Container.call(this); self.bucketGraphics = self.attachAsset('bucket', { anchorX: 0.5, anchorY: 0.5 }); self.bucketGraphics.visible = true; var closedGraphics = self.attachAsset('closed', { anchorX: 0.5, anchorY: 0.5 }); closedGraphics.visible = false; var bucketGraphics = self.bucketGraphics; self.update = function () { self.x = facekit.mouthCenter.x; self.y = facekit.mouthCenter.y; if (facekit.mouthOpen) { bucketGraphics.visible = true; closedGraphics.visible = false; } else { bucketGraphics.visible = false; closedGraphics.visible = true; } }; }); // Class for Falling Objects var FallingObject = Container.expand(function () { var self = Container.call(this); var objectGraphics = self.attachAsset('fallingObject', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; }; }); // Class for Power-ups var PowerUp = Container.expand(function () { var self = Container.call(this); var powerUpGraphics = self.attachAsset('powerUp', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.update = function () { self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ //<Assets used in the game will automatically appear here> // Initialize game elements var bucket = game.addChild(new Bucket()); bucket.x = 2048 / 2; bucket.y = 2500; var fallingObjects = []; var powerUps = []; var badItems = []; // Handle game move events game.move = function (x, y, obj) { bucket.x = x; }; // Update game logic game.update = function () { // Update falling objects for (var i = fallingObjects.length - 1; i >= 0; i--) { var obj = fallingObjects[i]; obj.update(); if (obj.y > 2732) { obj.destroy(); fallingObjects.splice(i, 1); // Show game over. The game will be automatically paused while game over is showing. LK.showGameOver(); } else if (obj.intersects(bucket)) { // Handle catching object obj.destroy(); fallingObjects.splice(i, 1); // Check if the mouth is open if (bucket.bucketGraphics.visible) { // Increment score when mouth touches an item LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); } else { // Show game over. The game will be automatically paused while game over is showing. LK.showGameOver(); } } } // Update power-ups for (var j = powerUps.length - 1; j >= 0; j--) { var powerUp = powerUps[j]; powerUp.update(); if (powerUp.y > 2732) { powerUp.destroy(); powerUps.splice(j, 1); } else if (powerUp.intersects(bucket)) { // Handle catching power-up powerUp.destroy(); powerUps.splice(j, 1); // Implement power-up effect } } // Update bad items for (var k = badItems.length - 1; k >= 0; k--) { var badItem = badItems[k]; badItem.update(); if (badItem.intersects(bucket)) { badItem.destroy(); badItems.splice(k, 1); // Decrease life count lifeCount--; // Remove a life icon var lostLife = lifeIcons.pop(); lostLife.destroy(); // Show game over when life count is 0. The game will be automatically paused while game over is showing. if (lifeCount === 0) { LK.showGameOver(); } } } // Spawn new falling objects if (LK.ticks % 60 == 0) { var newObject = new FallingObject(); newObject.x = Math.random() * 2048; newObject.y = 0; fallingObjects.push(newObject); game.addChild(newObject); } // Spawn bad items every few seconds if (LK.ticks % (80 + Math.floor(Math.random() * 80)) == 0) { var newBadItem = new BadItem(); newBadItem.x = Math.random() * 2048; newBadItem.y = 0; badItems.push(newBadItem); game.addChild(newBadItem); } }; // Display score var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.setText(LK.getScore()); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Initialize life count var lifeCount = 3; // Create an array to hold the life icons var lifeIcons = []; // Display life for (var i = 0; i < lifeCount; i++) { var life = LK.getAsset('life', { anchorX: 1, anchorY: 0, x: -i * 130 // Offset each life icon by 130 pixels }); lifeIcons.push(life); LK.gui.topRight.addChild(life); }
===================================================================
--- original.js
+++ change.js
@@ -157,9 +157,9 @@
fallingObjects.push(newObject);
game.addChild(newObject);
}
// Spawn bad items every few seconds
- if (LK.ticks % (60 + Math.floor(Math.random() * 60)) == 0) {
+ if (LK.ticks % (80 + Math.floor(Math.random() * 80)) == 0) {
var newBadItem = new BadItem();
newBadItem.x = Math.random() * 2048;
newBadItem.y = 0;
badItems.push(newBadItem);