/**** * Classes ****/ var Bird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); self.direction = Math.random() < 0.5 ? -1 : 1; self.originalX = self.direction === 1 ? 0 : 2048; self._move_migrated = function () {}; self._update_migrated = function () { self.x += self.direction * 1.5; // Further reduce speed for smoother movement 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(300, Math.min(2732 - 50 - self.height, self.y + Math.random() * 10 - 5)); }; }); var Branch = Container.expand(function () { var self = Container.call(this); var branchGraphics = self.attachAsset('branch', { anchorX: 0.5, anchorY: 0.5 }); self._move_migrated = function () {}; self._update_migrated = function () {}; }); var Hippo = Container.expand(function () { var self = Container.call(this); var hippoGraphics = self.attachAsset('hippo', { anchorX: 0.5, anchorY: 0.5, scaleX: 1, scaleY: 1 }); var hippoMouthOpen = false; self.vx = 0; self.vy = 0; self.gravity = 0.5; self.jumping = false; self.jump = function (target, branches) { if (target && !self.jumping) { self.jumping = true; var dx = target.x - self.x; var dy = target.y - self.y; if (dy > 0) { self.jumping = false; return; } var distance = Math.sqrt(dx * dx + dy * dy); self.vx = dx / distance * 25; // Increase speed for faster jump self.vy = dy / distance * 25; // Increase speed for faster jump self.jumpingFrom = branches; } }; self._update_migrated = function () { self.x = Math.max(0, Math.min(2048 - self.width, self.x + self.vx * 0.9)); // Apply easing effect if (self.vx > 0) { hippoGraphics.scale.x = -1; } else if (self.vx < 0) { hippoGraphics.scale.x = 1; } // Render hippo with mouth open if state is true if (hippoMouthOpen) { hippoGraphics.scale.y = 1.2; // Example of mouth open effect } else { hippoGraphics.scale.y = 1; } self.y += self.vy * 0.9; // Apply easing effect self.vy += self.gravity; if (self.vy > 0) { self.jumpingFrom = []; // Check if hippo is not intersecting any branch var onBranch = branches.some(function (branch) { return self.intersects(branch); }); if (!onBranch) { self.vy += self.gravity; // Continue falling } } if (self.y > 2732 - self.height) { self.y = 2732 - self.height; self.vy = -self.vy * 0.3; // Further reduce velocity for smoother bounce self.vx *= 0.3; // Further reduce horizontal velocity if (Math.abs(self.vy) < 1) { // Stop bouncing if velocity is too low self.vy = 0; self.vx = 0; self.jumping = false; } // Removed bounce effect and scale animation } }; }); var Spider = Container.expand(function () { var self = Container.call(this); var spiderGraphics = self.attachAsset('spider', { anchorX: 0.5, anchorY: 0.5 }); self.idle = true; self.moveDown = false; self.moveUp = false; self.state = 'idle'; self.originalY = self.y; self._update_migrated = function () { switch (self.state) { case 'idle': self.state = 'moveDown'; break; case 'moveDown': self.y += 1.5; // Further reduce speed for smoother movement if (self.y >= self.originalY + 3 * self.height) { self.state = 'moveUp'; } break; case 'moveUp': self.y -= 5; if (self.y <= self.originalY) { self.state = 'idle'; } break; default: break; } }; }); var TopBranch = Container.expand(function () { var self = Container.call(this); var topBranchGraphics = self.attachAsset('topBranch', { anchorY: 0.5 }); self.x = 0; self.y = 0; self.width = 2048; self._move_migrated = function () {}; self._update_migrated = function () {}; }); var Vine = Container.expand(function () { var self = Container.call(this); var vineGraphics = self.attachAsset('vine', { anchorX: 0.5, anchorY: 0.5 }); }); var Watermelon = Container.expand(function () { var self = Container.call(this); var watermelonGraphics = self.attachAsset('watermelon', { anchorX: 0.5, anchorY: 0.5 }); watermelonGraphics.scale.x = 2; watermelonGraphics.scale.y = 2; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ game.setupLevel = function () { for (var i = 0; i < branches.length; i++) { branches[i].destroy(); } branches = []; for (var i = 0; i < 25; i++) { // Increase the number of branches var newBranch = new Branch(); newBranch.x = Math.random() * 2048; // Randomize x position newBranch.y = Math.random() * 2300; // Randomize y position branches.push(newBranch); game.addChild(newBranch); if (i % 5 === 0) { // Reduce the number of watermelons var watermelonPrize = new Watermelon(); watermelonPrize.x = newBranch.x; watermelonPrize.y = newBranch.y - 50; // Position watermelon closer to the branch game.addChild(watermelonPrize); watermelons.push(watermelonPrize); } } for (var i = 0; i < birds.length; i++) { birds[i].destroy(); } birds = []; for (var i = 0; i < level + 1; i++) { // Reduce the number of birds // Add two more birds // Increase number of birds var newBird = new Bird(); newBird.x = Math.random() * 2048; newBird.y = i * (2732 / (2 + level)) + 300; birds.push(newBird); game.addChild(newBird); } for (var i = 0; i < watermelons.length; i++) { watermelons[i].destroy(); } watermelons = []; for (var i = 0; i < 20; i++) { // Reduce the number of watermelons for smoother gameplay // Increase the number of watermelons var newWatermelon = new Watermelon(); newWatermelon.x = Math.random() * 2048; newWatermelon.y = Math.random() * 2732; // Randomize y position across the entire screen game.addChild(newWatermelon); watermelons.push(newWatermelon); } for (var i = 0; i < spiders.length; i++) { spiders[i].destroy(); } spiders = []; for (var i = 0; i < Math.max(1, level - 1); i++) { // Reduce the number of spiders // Decrease number of spiders by one var newSpider = new Spider(); var eligibleBranches = branches.filter(function (branch) { return branch.y < 2732 * 2 / 3; }); var randomBranch = eligibleBranches[Math.floor(Math.random() * eligibleBranches.length)]; newSpider.x = randomBranch.x; newSpider.y = randomBranch.y + randomBranch.height; newSpider.originalY = newSpider.y; game.addChild(newSpider); spiders.push(newSpider); } var eligibleBranches = branches.filter(function (branch) { return branch.y < 2732 * 2 / 3; }); var randomBranch = eligibleBranches[Math.floor(Math.random() * eligibleBranches.length)]; newSpider.x = randomBranch.x; newSpider.y = randomBranch.y + randomBranch.height; newSpider.originalY = newSpider.y; game.addChild(newSpider); spiders.push(newSpider); // Add a new spider that moves horizontally var newSpiderHorizontal = new Spider(); newSpiderHorizontal.x = Math.random() * 2048; newSpiderHorizontal.y = Math.random() * 2732; newSpiderHorizontal.originalX = newSpiderHorizontal.x; newSpiderHorizontal._update_migrated = function () { switch (this.state) { case 'idle': this.state = 'moveRight'; break; case 'moveRight': this.x += 5; if (this.x >= this.originalX + 3 * this.width) { this.state = 'moveLeft'; } break; case 'moveLeft': this.x -= 5; if (this.x <= this.originalX) { this.state = 'idle'; } break; default: break; } }; game.addChild(newSpiderHorizontal); spiders.push(newSpiderHorizontal); var newVine = new Vine(); var vineBranch = eligibleBranches[Math.floor(Math.random() * eligibleBranches.length)]; newVine.x = vineBranch.x; newVine.y = vineBranch.y + 400; game.addChild(newVine); branches.sort(function (a, b) { return a.y - b.y; }); }; var branches = []; var birds = []; var watermelons = []; var spiders = []; var level = 1; var hippo = game.addChild(new Hippo()); hippo.x = 1024; hippo.y = 2732 - hippo.height - 100; // Adjusted initial position to prevent getting stuck // Removed initial upward velocity for the jump game.setupLevel(); var levelTxt = new Text2('Level: ' + level, { size: 75, fill: '#ffffff' }); levelTxt.anchor.set(0, 0); LK.gui.topLeft.addChild(levelTxt); var watermelonCount = 0; var watermelonTxt = new Text2('Watermelons: ' + watermelonCount, { size: 75, fill: '#ffffff' }); watermelonTxt.anchor.set(1, 0); LK.gui.topRight.addChild(watermelonTxt); // Removed duplicate hippo creation LK.on('tick', function () { hippo._update_migrated(); for (var i = 0; i < branches.length; i++) { branches[i]._update_migrated(); if (branches[i].y > 2732) { branches[i].destroy(); branches.splice(i, 1); i--; } } for (var i = 0; i < birds.length; i++) { birds[i]._update_migrated(); } for (var i = 0; i < branches.length; i++) { if (!hippo.jumpingFrom.includes(branches[i]) && hippo.intersects(branches[i])) { hippo.vx = 0; hippo.vy = 0; hippo.jumping = false; // Removed code to prevent hippo from landing on the branch } } if (hippo.y <= 0) { hippo.y = 0; hippo.vy = 0; } for (var i = 0; i < birds.length; i++) { if (hippo.intersects(birds[i])) { LK.showGameOver(); } birds[i]._update_migrated(); } for (var i = 0; i < watermelons.length; i++) { if (hippo.intersects(watermelons[i])) { watermelons[i].destroy(); watermelons.splice(i, 1); watermelonCount++; watermelonTxt.setText('Watermelons: ' + watermelonCount); LK.setScore(LK.getScore() + 1); // Removed the effect of the hippo getting bigger when grabbing watermelons // Toggle mouth open state hippoMouthOpen = true; LK.setTimeout(function () { hippoMouthOpen = false; }, 500); // Close mouth after 500ms } } for (var i = 0; i < spiders.length; i++) { spiders[i]._update_migrated(); if (hippo.intersects(spiders[i])) { LK.showGameOver(); } } }); game.on('down', function (x, y, obj) { var pos = game.toLocal(obj.global); hippo.jump({ x: pos.x, y: pos.y }, branches); });
/****
* Classes
****/
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdGraphics = self.attachAsset('bird', {
anchorX: 0.5,
anchorY: 0.5
});
self.direction = Math.random() < 0.5 ? -1 : 1;
self.originalX = self.direction === 1 ? 0 : 2048;
self._move_migrated = function () {};
self._update_migrated = function () {
self.x += self.direction * 1.5; // Further reduce speed for smoother movement
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(300, Math.min(2732 - 50 - self.height, self.y + Math.random() * 10 - 5));
};
});
var Branch = Container.expand(function () {
var self = Container.call(this);
var branchGraphics = self.attachAsset('branch', {
anchorX: 0.5,
anchorY: 0.5
});
self._move_migrated = function () {};
self._update_migrated = function () {};
});
var Hippo = Container.expand(function () {
var self = Container.call(this);
var hippoGraphics = self.attachAsset('hippo', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1,
scaleY: 1
});
var hippoMouthOpen = false;
self.vx = 0;
self.vy = 0;
self.gravity = 0.5;
self.jumping = false;
self.jump = function (target, branches) {
if (target && !self.jumping) {
self.jumping = true;
var dx = target.x - self.x;
var dy = target.y - self.y;
if (dy > 0) {
self.jumping = false;
return;
}
var distance = Math.sqrt(dx * dx + dy * dy);
self.vx = dx / distance * 25; // Increase speed for faster jump
self.vy = dy / distance * 25; // Increase speed for faster jump
self.jumpingFrom = branches;
}
};
self._update_migrated = function () {
self.x = Math.max(0, Math.min(2048 - self.width, self.x + self.vx * 0.9)); // Apply easing effect
if (self.vx > 0) {
hippoGraphics.scale.x = -1;
} else if (self.vx < 0) {
hippoGraphics.scale.x = 1;
}
// Render hippo with mouth open if state is true
if (hippoMouthOpen) {
hippoGraphics.scale.y = 1.2; // Example of mouth open effect
} else {
hippoGraphics.scale.y = 1;
}
self.y += self.vy * 0.9; // Apply easing effect
self.vy += self.gravity;
if (self.vy > 0) {
self.jumpingFrom = [];
// Check if hippo is not intersecting any branch
var onBranch = branches.some(function (branch) {
return self.intersects(branch);
});
if (!onBranch) {
self.vy += self.gravity; // Continue falling
}
}
if (self.y > 2732 - self.height) {
self.y = 2732 - self.height;
self.vy = -self.vy * 0.3; // Further reduce velocity for smoother bounce
self.vx *= 0.3; // Further reduce horizontal velocity
if (Math.abs(self.vy) < 1) {
// Stop bouncing if velocity is too low
self.vy = 0;
self.vx = 0;
self.jumping = false;
}
// Removed bounce effect and scale animation
}
};
});
var Spider = Container.expand(function () {
var self = Container.call(this);
var spiderGraphics = self.attachAsset('spider', {
anchorX: 0.5,
anchorY: 0.5
});
self.idle = true;
self.moveDown = false;
self.moveUp = false;
self.state = 'idle';
self.originalY = self.y;
self._update_migrated = function () {
switch (self.state) {
case 'idle':
self.state = 'moveDown';
break;
case 'moveDown':
self.y += 1.5; // Further reduce speed for smoother movement
if (self.y >= self.originalY + 3 * self.height) {
self.state = 'moveUp';
}
break;
case 'moveUp':
self.y -= 5;
if (self.y <= self.originalY) {
self.state = 'idle';
}
break;
default:
break;
}
};
});
var TopBranch = Container.expand(function () {
var self = Container.call(this);
var topBranchGraphics = self.attachAsset('topBranch', {
anchorY: 0.5
});
self.x = 0;
self.y = 0;
self.width = 2048;
self._move_migrated = function () {};
self._update_migrated = function () {};
});
var Vine = Container.expand(function () {
var self = Container.call(this);
var vineGraphics = self.attachAsset('vine', {
anchorX: 0.5,
anchorY: 0.5
});
});
var Watermelon = Container.expand(function () {
var self = Container.call(this);
var watermelonGraphics = self.attachAsset('watermelon', {
anchorX: 0.5,
anchorY: 0.5
});
watermelonGraphics.scale.x = 2;
watermelonGraphics.scale.y = 2;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
game.setupLevel = function () {
for (var i = 0; i < branches.length; i++) {
branches[i].destroy();
}
branches = [];
for (var i = 0; i < 25; i++) {
// Increase the number of branches
var newBranch = new Branch();
newBranch.x = Math.random() * 2048; // Randomize x position
newBranch.y = Math.random() * 2300; // Randomize y position
branches.push(newBranch);
game.addChild(newBranch);
if (i % 5 === 0) {
// Reduce the number of watermelons
var watermelonPrize = new Watermelon();
watermelonPrize.x = newBranch.x;
watermelonPrize.y = newBranch.y - 50; // Position watermelon closer to the branch
game.addChild(watermelonPrize);
watermelons.push(watermelonPrize);
}
}
for (var i = 0; i < birds.length; i++) {
birds[i].destroy();
}
birds = [];
for (var i = 0; i < level + 1; i++) {
// Reduce the number of birds
// Add two more birds
// Increase number of birds
var newBird = new Bird();
newBird.x = Math.random() * 2048;
newBird.y = i * (2732 / (2 + level)) + 300;
birds.push(newBird);
game.addChild(newBird);
}
for (var i = 0; i < watermelons.length; i++) {
watermelons[i].destroy();
}
watermelons = [];
for (var i = 0; i < 20; i++) {
// Reduce the number of watermelons for smoother gameplay
// Increase the number of watermelons
var newWatermelon = new Watermelon();
newWatermelon.x = Math.random() * 2048;
newWatermelon.y = Math.random() * 2732; // Randomize y position across the entire screen
game.addChild(newWatermelon);
watermelons.push(newWatermelon);
}
for (var i = 0; i < spiders.length; i++) {
spiders[i].destroy();
}
spiders = [];
for (var i = 0; i < Math.max(1, level - 1); i++) {
// Reduce the number of spiders
// Decrease number of spiders by one
var newSpider = new Spider();
var eligibleBranches = branches.filter(function (branch) {
return branch.y < 2732 * 2 / 3;
});
var randomBranch = eligibleBranches[Math.floor(Math.random() * eligibleBranches.length)];
newSpider.x = randomBranch.x;
newSpider.y = randomBranch.y + randomBranch.height;
newSpider.originalY = newSpider.y;
game.addChild(newSpider);
spiders.push(newSpider);
}
var eligibleBranches = branches.filter(function (branch) {
return branch.y < 2732 * 2 / 3;
});
var randomBranch = eligibleBranches[Math.floor(Math.random() * eligibleBranches.length)];
newSpider.x = randomBranch.x;
newSpider.y = randomBranch.y + randomBranch.height;
newSpider.originalY = newSpider.y;
game.addChild(newSpider);
spiders.push(newSpider);
// Add a new spider that moves horizontally
var newSpiderHorizontal = new Spider();
newSpiderHorizontal.x = Math.random() * 2048;
newSpiderHorizontal.y = Math.random() * 2732;
newSpiderHorizontal.originalX = newSpiderHorizontal.x;
newSpiderHorizontal._update_migrated = function () {
switch (this.state) {
case 'idle':
this.state = 'moveRight';
break;
case 'moveRight':
this.x += 5;
if (this.x >= this.originalX + 3 * this.width) {
this.state = 'moveLeft';
}
break;
case 'moveLeft':
this.x -= 5;
if (this.x <= this.originalX) {
this.state = 'idle';
}
break;
default:
break;
}
};
game.addChild(newSpiderHorizontal);
spiders.push(newSpiderHorizontal);
var newVine = new Vine();
var vineBranch = eligibleBranches[Math.floor(Math.random() * eligibleBranches.length)];
newVine.x = vineBranch.x;
newVine.y = vineBranch.y + 400;
game.addChild(newVine);
branches.sort(function (a, b) {
return a.y - b.y;
});
};
var branches = [];
var birds = [];
var watermelons = [];
var spiders = [];
var level = 1;
var hippo = game.addChild(new Hippo());
hippo.x = 1024;
hippo.y = 2732 - hippo.height - 100; // Adjusted initial position to prevent getting stuck
// Removed initial upward velocity for the jump
game.setupLevel();
var levelTxt = new Text2('Level: ' + level, {
size: 75,
fill: '#ffffff'
});
levelTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(levelTxt);
var watermelonCount = 0;
var watermelonTxt = new Text2('Watermelons: ' + watermelonCount, {
size: 75,
fill: '#ffffff'
});
watermelonTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(watermelonTxt);
// Removed duplicate hippo creation
LK.on('tick', function () {
hippo._update_migrated();
for (var i = 0; i < branches.length; i++) {
branches[i]._update_migrated();
if (branches[i].y > 2732) {
branches[i].destroy();
branches.splice(i, 1);
i--;
}
}
for (var i = 0; i < birds.length; i++) {
birds[i]._update_migrated();
}
for (var i = 0; i < branches.length; i++) {
if (!hippo.jumpingFrom.includes(branches[i]) && hippo.intersects(branches[i])) {
hippo.vx = 0;
hippo.vy = 0;
hippo.jumping = false;
// Removed code to prevent hippo from landing on the branch
}
}
if (hippo.y <= 0) {
hippo.y = 0;
hippo.vy = 0;
}
for (var i = 0; i < birds.length; i++) {
if (hippo.intersects(birds[i])) {
LK.showGameOver();
}
birds[i]._update_migrated();
}
for (var i = 0; i < watermelons.length; i++) {
if (hippo.intersects(watermelons[i])) {
watermelons[i].destroy();
watermelons.splice(i, 1);
watermelonCount++;
watermelonTxt.setText('Watermelons: ' + watermelonCount);
LK.setScore(LK.getScore() + 1);
// Removed the effect of the hippo getting bigger when grabbing watermelons
// Toggle mouth open state
hippoMouthOpen = true;
LK.setTimeout(function () {
hippoMouthOpen = false;
}, 500); // Close mouth after 500ms
}
}
for (var i = 0; i < spiders.length; i++) {
spiders[i]._update_migrated();
if (hippo.intersects(spiders[i])) {
LK.showGameOver();
}
}
});
game.on('down', function (x, y, obj) {
var pos = game.toLocal(obj.global);
hippo.jump({
x: pos.x,
y: pos.y
}, branches);
});
Cartoony looking spider, with two big round eyes Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cut watermelon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
bush. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tree. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
funny bird. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.