User prompt
Make it so u have a health bar which will take 2 hits from monkeys to get game over
User prompt
Make a home screen so you can exchange your points for bigger whips
User prompt
Make it so I can hold instead of tap to whip
User prompt
Make monkeys spawn 2x faster
User prompt
Make a whip noise every time I unleash a whip
User prompt
Make the background a jungle
User prompt
Make it every time I click there is a 0.5 second cool down before I can send a whip out again
User prompt
Every time I click make a whip sound
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'intersects')' in or related to this line: 'if (whips[j].intersects(monkeys[k])) {' Line Number: 103
Initial prompt
WHIPP MONKEYS
/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Define the Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { // Hero update logic }; self.whip = function () { var whip = new Whip(); whip.x = self.x; whip.y = self.y; whips.push(whip); game.addChild(whip); LK.getSound('Whiping1').play(); }; }); // Define the Monkey class var Monkey = Container.expand(function () { var self = Container.call(this); var monkeyGraphics = self.attachAsset('monkey', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); monkeys.splice(monkeys.indexOf(self), 1); } }; }); // Define the Whip class var Whip = Container.expand(function () { var self = Container.call(this); var whipGraphics = self.attachAsset('whip', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -15; self.update = function () { self.y += self.speed; if (self.y < 0) { self.destroy(); whips.splice(whips.indexOf(self), 1); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x228B22 // Jungle green background }); /**** * Game Code ****/ // Initialize arrays and variables var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - 200; var monkeys = []; var whips = []; var score = 0; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Function to handle game updates game.update = function () { // Update hero hero.update(); // Update monkeys for (var i = monkeys.length - 1; i >= 0; i--) { monkeys[i].update(); if (monkeys[i].intersects(hero)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } // Update whips for (var j = whips.length - 1; j >= 0; j--) { whips[j].update(); for (var k = monkeys.length - 1; k >= 0; k--) { if (whips[j] && monkeys[k] && whips[j].intersects(monkeys[k])) { monkeys[k].destroy(); whips[j].destroy(); monkeys.splice(k, 1); whips.splice(j, 1); score++; scoreTxt.setText(score); break; } } } // Spawn monkeys if (LK.ticks % 60 == 0) { var monkey = new Monkey(); monkey.x = Math.random() * 2048; monkey.y = -100; monkeys.push(monkey); game.addChild(monkey); } }; // Handle touch events for hero movement and whipping var lastWhipTime = 0; game.down = function (x, y, obj) { hero.x = x; hero.y = y; var currentTime = Date.now(); if (currentTime - lastWhipTime >= 500) { hero.whip(); lastWhipTime = currentTime; } }; game.move = function (x, y, obj) { hero.x = x; hero.y = y; }; game.up = function (x, y, obj) { // No action needed on touch up };
===================================================================
--- original.js
+++ change.js
@@ -114,12 +114,17 @@
game.addChild(monkey);
}
};
// Handle touch events for hero movement and whipping
+var lastWhipTime = 0;
game.down = function (x, y, obj) {
hero.x = x;
hero.y = y;
- hero.whip();
+ var currentTime = Date.now();
+ if (currentTime - lastWhipTime >= 500) {
+ hero.whip();
+ lastWhipTime = currentTime;
+ }
};
game.move = function (x, y, obj) {
hero.x = x;
hero.y = y;
Banana. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Jungle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2 hearts. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Golden trophy. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.