/**** * Classes ****/ // Banana class representing collectible items var Banana = Container.expand(function () { var self = Container.call(this); var bananaGraphics = self.attachAsset('banana', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Increase the falling speed of the banana over time self.y += 1 + LK.ticks / 5000; }; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Explorer class representing the player character var Explorer = Container.expand(function () { var self = Container.call(this); var explorerGraphics = self.attachAsset('explorer', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); self.speed = 10; self.update = function () { // Logic for explorer movement }; self.collectBanana = function () { // Logic for collecting bananas }; self.useSlingshot = function () { // Logic for using slingshot }; }); // Obstacle class representing snakes, rocks, and quicksand var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Increase the falling speed of the obstacle over time self.y += 1 + LK.ticks / 5000; }; }); // Slingshot class representing special item var Slingshot = Container.expand(function () { var self = Container.call(this); var slingshotGraphics = self.attachAsset('slingshot', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Increase the falling speed of the slingshot over time self.y += 2 + LK.ticks / 2500; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x228B22 // Init game with forest green background }); /**** * Game Code ****/ // Initialize game elements var explorer = game.addChild(new Explorer()); explorer.x = 1024; // Center horizontally explorer.y = 2000; // Initial vertical position var bananas = []; var obstacles = []; var slingshots = []; // Function to spawn bananas function spawnBanana() { var banana = new Banana(); banana.x = Math.random() * 2048; banana.y = Math.random() * 2732; bananas.push(banana); game.addChild(banana); } // Function to spawn obstacles function spawnObstacle() { var obstacle = new Obstacle(); obstacle.x = Math.random() * 2048; obstacle.y = Math.random() * 2732; obstacles.push(obstacle); game.addChild(obstacle); } // Function to spawn slingshots function spawnSlingshot() { var slingshot = new Slingshot(); slingshot.x = Math.random() * 2048; slingshot.y = Math.random() * 2732; slingshots.push(slingshot); game.addChild(slingshot); } // Game update loop game.update = function () { // Update explorer explorer.update(); // Update bananas for (var i = bananas.length - 1; i >= 0; i--) { bananas[i].update(); if (explorer.intersects(bananas[i])) { explorer.collectBanana(); // Add flash effect when explorer makes contact with banana LK.effects.flashObject(bananas[i], 0xffffff, 500); // Create a fun animation effect when explorer gets a banana LK.effects.flashObject(bananas[i], 0xffffff, 500); bananas[i].destroy(); bananas.splice(i, 1); } } // Update obstacles for (var i = obstacles.length - 1; i >= 0; i--) { obstacles[i].update(); if (explorer.intersects(obstacles[i])) { // Handle collision with obstacle LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } // Update slingshots for (var i = slingshots.length - 1; i >= 0; i--) { slingshots[i].update(); if (explorer.intersects(slingshots[i])) { explorer.useSlingshot(); slingshots[i].destroy(); slingshots.splice(i, 1); } } // Spawn new items periodically if (LK.ticks % 30 === 0) { spawnBanana(); } if (LK.ticks % 180 === 0) { spawnObstacle(); } if (LK.ticks % 75 === 0) { spawnSlingshot(); } }; // Event listeners for touch controls game.down = function (x, y, obj) { // Set explorer to follow mouse drag explorer.x = x; explorer.y = y; // Make the explorer jump towards the banana for (var i = bananas.length - 1; i >= 0; i--) { if (explorer.intersects(bananas[i])) { explorer.collectBanana(); // Make the explorer jump one time very high when it intersects with a banana explorer.y -= 150; LK.setTimeout(function () { explorer.y += 150; }, 200); bananas[i].destroy(); bananas.splice(i, 1); // Add 3 points when explorer intersects with banana LK.setScore(LK.getScore() + 3); } } }; game.up = function (x, y, obj) { // Make the explorer jump towards the banana for (var i = bananas.length - 1; i >= 0; i--) { if (explorer.intersects(bananas[i])) { explorer.collectBanana(); // Make the explorer jump one time very high when it intersects with a banana explorer.y -= 150; LK.setTimeout(function () { explorer.y += 150; }, 200); bananas[i].destroy(); bananas.splice(i, 1); // Add 3 points when explorer intersects with banana LK.setScore(LK.getScore() + 3); } } // Check if explorer intersects with banana, obstacle or slingshot for (var i = bananas.length - 1; i >= 0; i--) { if (explorer.intersects(bananas[i])) { explorer.collectBanana(); // Make the explorer jump with 5 bounces when it intersects with a banana explorer.y -= 50; LK.setTimeout(function () { explorer.y += 25; }, 100); LK.setTimeout(function () { explorer.y -= 25; }, 200); LK.setTimeout(function () { explorer.y += 25; }, 300); LK.setTimeout(function () { explorer.y -= 25; }, 400); LK.setTimeout(function () { explorer.y += 25; }, 500); LK.setTimeout(function () { explorer.y -= 25; }, 600); LK.setTimeout(function () { explorer.y += 25; }, 700); LK.setTimeout(function () { explorer.y -= 25; }, 800); LK.setTimeout(function () { explorer.y += 25; }, 900); bananas[i].destroy(); bananas.splice(i, 1); // Add 3 points when explorer intersects with banana LK.setScore(LK.getScore() + 3); } } for (var i = obstacles.length - 1; i >= 0; i--) { if (explorer.intersects(obstacles[i])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } for (var i = slingshots.length - 1; i >= 0; i--) { if (explorer.intersects(slingshots[i])) { explorer.useSlingshot(); // Make the explorer jump with a one time bounce effect when it intersects with a slingshot explorer.y -= 300; LK.setTimeout(function () { explorer.y += 300; }, 100); slingshots[i].destroy(); slingshots.splice(i, 1); // Add 5 points when explorer intersects with slingshot LK.setScore(LK.getScore() + 1); } } };
/****
* Classes
****/
// Banana class representing collectible items
var Banana = Container.expand(function () {
var self = Container.call(this);
var bananaGraphics = self.attachAsset('banana', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Increase the falling speed of the banana over time
self.y += 1 + LK.ticks / 5000;
};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Explorer class representing the player character
var Explorer = Container.expand(function () {
var self = Container.call(this);
var explorerGraphics = self.attachAsset('explorer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
});
self.speed = 10;
self.update = function () {
// Logic for explorer movement
};
self.collectBanana = function () {
// Logic for collecting bananas
};
self.useSlingshot = function () {
// Logic for using slingshot
};
});
// Obstacle class representing snakes, rocks, and quicksand
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Increase the falling speed of the obstacle over time
self.y += 1 + LK.ticks / 5000;
};
});
// Slingshot class representing special item
var Slingshot = Container.expand(function () {
var self = Container.call(this);
var slingshotGraphics = self.attachAsset('slingshot', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Increase the falling speed of the slingshot over time
self.y += 2 + LK.ticks / 2500;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x228B22 // Init game with forest green background
});
/****
* Game Code
****/
// Initialize game elements
var explorer = game.addChild(new Explorer());
explorer.x = 1024; // Center horizontally
explorer.y = 2000; // Initial vertical position
var bananas = [];
var obstacles = [];
var slingshots = [];
// Function to spawn bananas
function spawnBanana() {
var banana = new Banana();
banana.x = Math.random() * 2048;
banana.y = Math.random() * 2732;
bananas.push(banana);
game.addChild(banana);
}
// Function to spawn obstacles
function spawnObstacle() {
var obstacle = new Obstacle();
obstacle.x = Math.random() * 2048;
obstacle.y = Math.random() * 2732;
obstacles.push(obstacle);
game.addChild(obstacle);
}
// Function to spawn slingshots
function spawnSlingshot() {
var slingshot = new Slingshot();
slingshot.x = Math.random() * 2048;
slingshot.y = Math.random() * 2732;
slingshots.push(slingshot);
game.addChild(slingshot);
}
// Game update loop
game.update = function () {
// Update explorer
explorer.update();
// Update bananas
for (var i = bananas.length - 1; i >= 0; i--) {
bananas[i].update();
if (explorer.intersects(bananas[i])) {
explorer.collectBanana();
// Add flash effect when explorer makes contact with banana
LK.effects.flashObject(bananas[i], 0xffffff, 500);
// Create a fun animation effect when explorer gets a banana
LK.effects.flashObject(bananas[i], 0xffffff, 500);
bananas[i].destroy();
bananas.splice(i, 1);
}
}
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].update();
if (explorer.intersects(obstacles[i])) {
// Handle collision with obstacle
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
// Update slingshots
for (var i = slingshots.length - 1; i >= 0; i--) {
slingshots[i].update();
if (explorer.intersects(slingshots[i])) {
explorer.useSlingshot();
slingshots[i].destroy();
slingshots.splice(i, 1);
}
}
// Spawn new items periodically
if (LK.ticks % 30 === 0) {
spawnBanana();
}
if (LK.ticks % 180 === 0) {
spawnObstacle();
}
if (LK.ticks % 75 === 0) {
spawnSlingshot();
}
};
// Event listeners for touch controls
game.down = function (x, y, obj) {
// Set explorer to follow mouse drag
explorer.x = x;
explorer.y = y;
// Make the explorer jump towards the banana
for (var i = bananas.length - 1; i >= 0; i--) {
if (explorer.intersects(bananas[i])) {
explorer.collectBanana();
// Make the explorer jump one time very high when it intersects with a banana
explorer.y -= 150;
LK.setTimeout(function () {
explorer.y += 150;
}, 200);
bananas[i].destroy();
bananas.splice(i, 1);
// Add 3 points when explorer intersects with banana
LK.setScore(LK.getScore() + 3);
}
}
};
game.up = function (x, y, obj) {
// Make the explorer jump towards the banana
for (var i = bananas.length - 1; i >= 0; i--) {
if (explorer.intersects(bananas[i])) {
explorer.collectBanana();
// Make the explorer jump one time very high when it intersects with a banana
explorer.y -= 150;
LK.setTimeout(function () {
explorer.y += 150;
}, 200);
bananas[i].destroy();
bananas.splice(i, 1);
// Add 3 points when explorer intersects with banana
LK.setScore(LK.getScore() + 3);
}
}
// Check if explorer intersects with banana, obstacle or slingshot
for (var i = bananas.length - 1; i >= 0; i--) {
if (explorer.intersects(bananas[i])) {
explorer.collectBanana();
// Make the explorer jump with 5 bounces when it intersects with a banana
explorer.y -= 50;
LK.setTimeout(function () {
explorer.y += 25;
}, 100);
LK.setTimeout(function () {
explorer.y -= 25;
}, 200);
LK.setTimeout(function () {
explorer.y += 25;
}, 300);
LK.setTimeout(function () {
explorer.y -= 25;
}, 400);
LK.setTimeout(function () {
explorer.y += 25;
}, 500);
LK.setTimeout(function () {
explorer.y -= 25;
}, 600);
LK.setTimeout(function () {
explorer.y += 25;
}, 700);
LK.setTimeout(function () {
explorer.y -= 25;
}, 800);
LK.setTimeout(function () {
explorer.y += 25;
}, 900);
bananas[i].destroy();
bananas.splice(i, 1);
// Add 3 points when explorer intersects with banana
LK.setScore(LK.getScore() + 3);
}
}
for (var i = obstacles.length - 1; i >= 0; i--) {
if (explorer.intersects(obstacles[i])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
for (var i = slingshots.length - 1; i >= 0; i--) {
if (explorer.intersects(slingshots[i])) {
explorer.useSlingshot();
// Make the explorer jump with a one time bounce effect when it intersects with a slingshot
explorer.y -= 300;
LK.setTimeout(function () {
explorer.y += 300;
}, 100);
slingshots[i].destroy();
slingshots.splice(i, 1);
// Add 5 points when explorer intersects with slingshot
LK.setScore(LK.getScore() + 1);
}
}
};
simple snake image. transparent background.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
yellow orb like a diamond cut gem. transparent background.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A rough edged rock. Transparent image.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute robot. Transparent background.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.