User prompt
Remove branches.length > 0 as condition for jump
User prompt
Monkey's jump function should receive not just a branch parameter, but branches, containing all branches currently intersected with monkey
User prompt
Fix Bug: 'ReferenceError: branches is not defined' in this line: 'for (var i = 0; i < branches.length; i++) {' Line Number: 51
User prompt
On jump, set jumpingFrom with all branches intersecting with monkey, not just one branch
User prompt
Make jumpingFrom an array containing all intersecting branches with monkey. Adjust the code as necessary
User prompt
Invert monkey sprite flipping condition
User prompt
✅ Flip the monkey sprite horizontally when its X direction is -1
User prompt
Flip the monkey sprite horizontally when its X direction is 1
User prompt
Flip the bird sprite horizontally when its direction is -1
User prompt
On setupLevel, set the top-branch Y position to be it's height/2
User prompt
top branch Y position should be a little bit higher. It's top edge must coincide with the screen top edge
User prompt
top branch should be a little bit lower. It's top edge must coincide with the screen top edge
User prompt
Make the top height twice the height
User prompt
The top branch should have a special sprite, and should be a rectangle that takes the whole width of the screen
User prompt
Adjust the Z position of the pop-up to be above everything lese
User prompt
DIsplay an intro pop-up that explains the game
User prompt
Reduce branches from 20 to 15
User prompt
Don't set jumping to false when vy > 0. Set it to false when a branch is touched, or when Y reaches the ground
User prompt
Prevent birds from going through top and bottom screen boundaries, with some padding
User prompt
Don't allow double-jumps
User prompt
Starting the game with one less bird than current
User prompt
On setupLevel, destroy birds before creating new ones. Also, have 3 initial birds but one additional more for each subsequent level
User prompt
Make birds 30% slower and make sure their initial Y positions are well-spaced out on screen
User prompt
Only call setupLevel once the branches and birds array are set
User prompt
When a bird is set with direction 1, it's X position must start on 0. When it's direction is -1, it's X must be the screen right side
var TopBranch = Container.expand(function () { var self = Container.call(this); var topBranchGraphics = self.createAsset('topBranch', 'Top Branch Graphics', 0, .5); self.x = 0; self.y = 0; self.width = 2048; self.move = function () {}; self.update = function () {}; }); var Branch = Container.expand(function () { var self = Container.call(this); var branchGraphics = self.createAsset('branch', 'Branch Graphics', .5, .5); self.move = function () {}; self.update = function () {}; }); var Bird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.createAsset('bird', 'Bird Graphics', .5, .5); self.direction = Math.random() < 0.5 ? -1 : 1; self.originalX = self.direction === 1 ? 0 : 2048; self.move = function () {}; self.update = function () { self.x += self.direction * 7; if (self.direction === -1) { birdGraphics.scale.x = -1; } else { birdGraphics.scale.x = 1; } if (self.x < 0 || self.x > 2048) { self.x = self.originalX; } self.y = Math.max(50, Math.min(2732 - 50 - self.height, self.y + Math.random() * 10 - 5)); }; }); var Monkey = Container.expand(function () { var self = Container.call(this); var monkeyGraphics = self.createAsset('monkey', 'Monkey Graphics', .5, .5); self.vx = 0; self.vy = 0; self.gravity = 0.5; self.jumping = false; self.jump = function (target, branch) { if (target && !self.jumping) { self.jumping = true; var dx = target.x - self.x; var dy = target.y - self.y; if (dy > 0) return; var distance = Math.sqrt(dx * dx + dy * dy); self.vx = dx / distance * 25; self.vy = dy / distance * 25; self.jumpingFrom = branch; } }; self.update = function () { self.x = Math.max(0, Math.min(2048 - self.width, self.x + self.vx)); self.y += self.vy; self.vy += self.gravity; if (self.vy > 0) { self.jumpingFrom = null; } if (self.y > 2732 - self.height) { self.y = 2732 - self.height; self.vy = 0; self.vx = 0; self.jumping = false; } }; }); var Game = Container.expand(function () { var self = Container.call(this); var introPopup = new Text2('Welcome to Monkey Climb!\nClick on branches to climb.\nAvoid the birds!', { size: 100, fill: '#ffffff' }); introPopup.anchor.set(.5, .5); introPopup.x = 1024; introPopup.y = 1366; self.addChildAt(introPopup, self.children.length); LK.setTimeout(function () { introPopup.destroy(); }, 5000); self.setupLevel = function () { for (var i = 0; i < branches.length; i++) { branches[i].destroy(); } branches = []; for (var i = 0; i < 15; i++) { var newBranch = new Branch(); newBranch.x = Math.random() * 2048; newBranch.y = i * (2732 / 15); branches.push(newBranch); self.addChild(newBranch); } for (var i = 0; i < birds.length; i++) { birds[i].destroy(); } birds = []; for (var i = 0; i < 2 + level; i++) { var newBird = new Bird(); newBird.x = Math.random() * 2048; newBird.y = i * (2732 / (2 + level)); birds.push(newBird); self.addChild(newBird); } branches.sort(function (a, b) { return a.y - b.y; }); self.topBranch = new TopBranch(); self.topBranch.y = self.topBranch.height / 2; self.addChild(self.topBranch); branches[0] = self.topBranch; }; var branches = []; var birds = []; var level = 1; self.setupLevel(); var levelTxt = new Text2('Level: ' + level, { size: 150, fill: '#ffffff' }); levelTxt.anchor.set(.5, 0); LK.gui.topCenter.addChild(levelTxt); var monkey = self.addChild(new Monkey()); monkey.x = 1024; monkey.y = 2732 - monkey.height; LK.on('tick', function () { monkey.update(); for (var i = 0; i < branches.length; i++) { branches[i].update(); if (branches[i].y > 2732) { branches[i].destroy(); branches.splice(i, 1); i--; } } for (var i = 0; i < birds.length; i++) { birds[i].update(); } for (var i = 0; i < branches.length; i++) { if (branches[i] !== monkey.jumpingFrom && monkey.intersects(branches[i])) { monkey.vx = 0; monkey.vy = 0; monkey.jumping = false; } } if (monkey.intersects(self.topBranch)) { monkey.x = 1024; monkey.y = 2732 - monkey.height; level++; levelTxt.setText('Level: ' + level); self.setupLevel(); } for (var i = 0; i < birds.length; i++) { if (monkey.intersects(birds[i])) { LK.showGameOver(); } birds[i].update(); } }); stage.on('down', function (obj) { var pos = obj.event.getLocalPosition(self); var currentBranch = null; for (var i = 0; i < branches.length; i++) { if (monkey.intersects(branches[i])) { currentBranch = branches[i]; break; } } monkey.jump({ x: pos.x, y: pos.y }, currentBranch); }); });
===================================================================
--- original.js
+++ change.js
@@ -20,8 +20,13 @@
self.originalX = self.direction === 1 ? 0 : 2048;
self.move = function () {};
self.update = function () {
self.x += self.direction * 7;
+ if (self.direction === -1) {
+ birdGraphics.scale.x = -1;
+ } else {
+ birdGraphics.scale.x = 1;
+ }
if (self.x < 0 || self.x > 2048) {
self.x = self.originalX;
}
self.y = Math.max(50, Math.min(2732 - 50 - self.height, self.y + Math.random() * 10 - 5));
A tree branch with green leaves Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A preying white bird flying ahead Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A cute monkey with arms up Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Wood texture Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Bananas Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cartoony looking spider, with two big round eyes Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
One green vine Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.