Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: isHeartAlreadyFalling is not defined' in or related to this line: 'if (!isHeartAlreadyFalling()) {' Line Number: 360
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'active')' in or related to this line: 'if (!item.active || item.alpha <= 0) {' Line Number: 413
User prompt
When we click on the bananas, the heart effect appears. Delete it. Just leave the banana effect. Fix it and do it
User prompt
When we click on the bananas, change it to a banana effect. do this
User prompt
If the score is 50 and there is 1 life, only 1 heart will come. If no heart is taken, 1 more heart will come after 20 scores. Do this
User prompt
When our health is low, if the heart that appears reaches the minimum requirement of 50 points, if it has 1 health, it will appear and this will now be automatic for 50+, but the chance of appearing will be 40%.
User prompt
Better dynamically adjust souls' positions ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Add a click to play text when the game is opened and start only when the game is clicked to start
User prompt
Now let's change the appearance of the score to make it thicker. Let's do it
User prompt
Rotten bananas will drop, which have the same acceleration and drop rate as bombs, and will decrease our health when touched. They will spawn when the score exceeds 30. Create a new Asset. Let's do it
User prompt
Rotten bananas will drop, which have the same acceleration and drop rate as bombs, and will decrease our health when touched. They will spawn when the score exceeds 30.
User prompt
Cennet server error. Fix this Error
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'lastY')' in or related to this line: 'if (item.lastY < SCREEN_HEIGHT && item.y >= SCREEN_HEIGHT) {' Line Number: 228. Fix this Error
User prompt
If we are low on health after 100 points, let the falling speed of the incoming heart be 16x
User prompt
If he has passed 100 points and only has 1 heart left, only 1 heart will spawn on the screen and think about it. If he can't catch it, he won't be able to get it, but if he clicks, he will get 1 life. After getting the life, it will not appear again.
User prompt
What you will add: bananas 14x after 150 scores, 15x after 160 scores, 16x after 170 scores, 17x after 180 scores, 18x after 190 scores, 19x after 200 scores, 20x. Do this banana acceleration.
User prompt
What you will add: bananas 9x after 90 scores, 9.5x after 100 scores, 10x after 110 scores, 10.5x after 120 scores, 11x after 130 scores, 12x after 140 scores, 13x. Do this banana acceleration.
User prompt
Things to add: Bananas increase 6x after 30 scores, 6.5x after 40 scores, 7x after 50 scores, 7.5x after 60 scores, 8x after 70 scores and 8.5x after 80 scores. Add these bananas to the speedup code.
User prompt
Increase your speed in this order. After 5 scores 2x, after 10 scores 3x, after 20 scores 5x% etc. I want you to do this.
User prompt
Please fix the bug: 'Uncaught TypeError: tween.to is not a function' in or related to this line: 'tween.to(self, 0.2, {' Line Number: 79 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please save this source code
Code edit (1 edits merged)
Please save this source code
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Banana = Container.expand(function () { var self = Container.call(this); var bananaGraphics = self.attachAsset('banana', { anchorX: 0.5, anchorY: 0.5, rotation: Math.PI / 6 }); self.fallSpeed = 5; self.isActive = true; self.update = function () { if (self.isActive) { self.y += self.fallSpeed; if (self.rotation) { self.rotation += 0.01; } } }; self.down = function (x, y, obj) { if (self.isActive) { LK.getSound('pop').play(); LK.setScore(LK.getScore() + 1); self.isActive = false; tween(self, { alpha: 0, scaleX: 1.5, scaleY: 1.5 }, { duration: 300, onFinish: function onFinish() { self.destroy(); } }); } }; return self; }); var Bomb = Container.expand(function () { var self = Container.call(this); var bombGraphics = self.attachAsset('bomb', { anchorX: 0.5, anchorY: 0.5 }); self.fallSpeed = 6; self.isActive = true; self.update = function () { if (self.isActive) { self.y += self.fallSpeed; if (self.rotation) { self.rotation += 0.02; } } }; self.down = function (x, y, obj) { if (self.isActive) { LK.getSound('explosion').play(); decreaseLives(); self.isActive = false; // Flash the bomb and make it disappear tween(self, { alpha: 0, scaleX: 2, scaleY: 2 }, { duration: 300, onFinish: function onFinish() { self.destroy(); } }); // Flash the screen red LK.effects.flashScreen(0xff0000, 300); } }; return self; }); var Heart = Container.expand(function () { var self = Container.call(this); var heartGraphics = self.attachAsset('heart', { anchorX: 5.0, anchorY: 5.0 }); self.setActive = function (active) { heartGraphics.alpha = active ? 1 : 0.3; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game variables var fallingObjects = []; var spawnTimer = null; var difficultyTimer = null; var spawnInterval = 1500; var minSpawnInterval = 500; var currentLevel = 1; var lives = 3; var hearts = []; var gameRunning = false; var bombThreshold = 15; // Score threshold for bombs to appear var bombProbability = 0.2; // Initial probability of spawning a bomb // Set up the game background var background = LK.getAsset('background', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); game.addChild(background); // Set up the score display var scoreTxt = new Text2('0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); scoreTxt.y = 20; LK.gui.top.addChild(scoreTxt); // Set up lives display function setupLives() { // Clear existing hearts if any for (var i = 0; i < hearts.length; i++) { if (hearts[i].parent) { hearts[i].parent.removeChild(hearts[i]); } } hearts = []; for (var i = 0; i < 3; i++) { var heart = new Heart(); heart.x = 60 + i * 80; heart.y = 60; heart.setActive(i < lives); LK.gui.addChild(heart); hearts.push(heart); } } // Start the game function startGame() { LK.setScore(0); lives = 3; currentLevel = 1; spawnInterval = 1500; bombProbability = 0.2; gameRunning = true; // Clear any existing objects for (var i = 0; i < fallingObjects.length; i++) { if (fallingObjects[i].parent) { fallingObjects[i].destroy(); } } fallingObjects = []; // Clear any existing timers if (spawnTimer) { LK.clearInterval(spawnTimer); } if (difficultyTimer) { LK.clearInterval(difficultyTimer); } // Setup lives display setupLives(); // Start spawning objects spawnTimer = LK.setInterval(spawnObject, spawnInterval); // Increase difficulty over time difficultyTimer = LK.setInterval(increaseDifficulty, 10000); // Play background music LK.playMusic('gameMusic', { fade: { start: 0, end: 0.4, duration: 1000 } }); } // Spawn a new falling object (banana or bomb) function spawnObject() { if (!gameRunning) { return; } var isBomb = LK.getScore() >= bombThreshold && Math.random() < bombProbability; var object = null; if (isBomb) { object = new Bomb(); object.fallSpeed = Math.min(12, 6 + currentLevel * 0.5); object.rotation = Math.random() * Math.PI * 2; } else { object = new Banana(); object.fallSpeed = Math.min(12, 5 + currentLevel * 0.5); object.rotation = Math.random() * Math.PI / 4; } // Position randomly across the width of the screen object.x = Math.random() * (2048 - 200) + 100; object.y = -100; game.addChild(object); fallingObjects.push(object); } // Increase game difficulty function increaseDifficulty() { if (!gameRunning) { return; } currentLevel++; // Increase spawn rate if (spawnInterval > minSpawnInterval) { spawnInterval = Math.max(minSpawnInterval, spawnInterval - 200); // Reset the spawn timer with new interval LK.clearInterval(spawnTimer); spawnTimer = LK.setInterval(spawnObject, spawnInterval); } // Increase bomb probability if (LK.getScore() >= bombThreshold) { bombProbability = Math.min(0.4, bombProbability + 0.05); } } // Decrease player lives function decreaseLives() { lives--; // Update hearts display for (var i = 0; i < hearts.length; i++) { hearts[i].setActive(i < lives); } if (lives <= 0) { gameOver(); } } // Game over handling function gameOver() { gameRunning = false; LK.getSound('gameover').play(); LK.clearInterval(spawnTimer); LK.clearInterval(difficultyTimer); // Fade out music LK.playMusic('gameMusic', { fade: { start: 0.4, end: 0, duration: 1000 } }); // Show game over screen after a short delay LK.setTimeout(function () { LK.showGameOver(); }, 1000); } // Handle objects that reach the bottom of the screen function handleOffscreenObjects() { for (var i = fallingObjects.length - 1; i >= 0; i--) { var obj = fallingObjects[i]; if (obj.y > 2732 + 100) { // Object fell off the bottom of the screen if (obj.isActive && obj instanceof Banana) { // Player missed a banana decreaseLives(); } obj.destroy(); fallingObjects.splice(i, 1); } } } // Update the game state every frame game.update = function () { if (!gameRunning && lives > 0) { startGame(); } if (gameRunning) { handleOffscreenObjects(); updateScore(); } }; // Update the score display function updateScore() { scoreTxt.setText(LK.getScore().toString()); } // Start game when loaded LK.setTimeout(function () { startGame(); }, 500);
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Banana = Container.expand(function () {
var self = Container.call(this);
var bananaGraphics = self.attachAsset('banana', {
anchorX: 0.5,
anchorY: 0.5,
rotation: Math.PI / 6
});
self.fallSpeed = 5;
self.isActive = true;
self.update = function () {
if (self.isActive) {
self.y += self.fallSpeed;
if (self.rotation) {
self.rotation += 0.01;
}
}
};
self.down = function (x, y, obj) {
if (self.isActive) {
LK.getSound('pop').play();
LK.setScore(LK.getScore() + 1);
self.isActive = false;
tween(self, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 300,
onFinish: function onFinish() {
self.destroy();
}
});
}
};
return self;
});
var Bomb = Container.expand(function () {
var self = Container.call(this);
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
self.fallSpeed = 6;
self.isActive = true;
self.update = function () {
if (self.isActive) {
self.y += self.fallSpeed;
if (self.rotation) {
self.rotation += 0.02;
}
}
};
self.down = function (x, y, obj) {
if (self.isActive) {
LK.getSound('explosion').play();
decreaseLives();
self.isActive = false;
// Flash the bomb and make it disappear
tween(self, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 300,
onFinish: function onFinish() {
self.destroy();
}
});
// Flash the screen red
LK.effects.flashScreen(0xff0000, 300);
}
};
return self;
});
var Heart = Container.expand(function () {
var self = Container.call(this);
var heartGraphics = self.attachAsset('heart', {
anchorX: 5.0,
anchorY: 5.0
});
self.setActive = function (active) {
heartGraphics.alpha = active ? 1 : 0.3;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Game variables
var fallingObjects = [];
var spawnTimer = null;
var difficultyTimer = null;
var spawnInterval = 1500;
var minSpawnInterval = 500;
var currentLevel = 1;
var lives = 3;
var hearts = [];
var gameRunning = false;
var bombThreshold = 15; // Score threshold for bombs to appear
var bombProbability = 0.2; // Initial probability of spawning a bomb
// Set up the game background
var background = LK.getAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
game.addChild(background);
// Set up the score display
var scoreTxt = new Text2('0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.y = 20;
LK.gui.top.addChild(scoreTxt);
// Set up lives display
function setupLives() {
// Clear existing hearts if any
for (var i = 0; i < hearts.length; i++) {
if (hearts[i].parent) {
hearts[i].parent.removeChild(hearts[i]);
}
}
hearts = [];
for (var i = 0; i < 3; i++) {
var heart = new Heart();
heart.x = 60 + i * 80;
heart.y = 60;
heart.setActive(i < lives);
LK.gui.addChild(heart);
hearts.push(heart);
}
}
// Start the game
function startGame() {
LK.setScore(0);
lives = 3;
currentLevel = 1;
spawnInterval = 1500;
bombProbability = 0.2;
gameRunning = true;
// Clear any existing objects
for (var i = 0; i < fallingObjects.length; i++) {
if (fallingObjects[i].parent) {
fallingObjects[i].destroy();
}
}
fallingObjects = [];
// Clear any existing timers
if (spawnTimer) {
LK.clearInterval(spawnTimer);
}
if (difficultyTimer) {
LK.clearInterval(difficultyTimer);
}
// Setup lives display
setupLives();
// Start spawning objects
spawnTimer = LK.setInterval(spawnObject, spawnInterval);
// Increase difficulty over time
difficultyTimer = LK.setInterval(increaseDifficulty, 10000);
// Play background music
LK.playMusic('gameMusic', {
fade: {
start: 0,
end: 0.4,
duration: 1000
}
});
}
// Spawn a new falling object (banana or bomb)
function spawnObject() {
if (!gameRunning) {
return;
}
var isBomb = LK.getScore() >= bombThreshold && Math.random() < bombProbability;
var object = null;
if (isBomb) {
object = new Bomb();
object.fallSpeed = Math.min(12, 6 + currentLevel * 0.5);
object.rotation = Math.random() * Math.PI * 2;
} else {
object = new Banana();
object.fallSpeed = Math.min(12, 5 + currentLevel * 0.5);
object.rotation = Math.random() * Math.PI / 4;
}
// Position randomly across the width of the screen
object.x = Math.random() * (2048 - 200) + 100;
object.y = -100;
game.addChild(object);
fallingObjects.push(object);
}
// Increase game difficulty
function increaseDifficulty() {
if (!gameRunning) {
return;
}
currentLevel++;
// Increase spawn rate
if (spawnInterval > minSpawnInterval) {
spawnInterval = Math.max(minSpawnInterval, spawnInterval - 200);
// Reset the spawn timer with new interval
LK.clearInterval(spawnTimer);
spawnTimer = LK.setInterval(spawnObject, spawnInterval);
}
// Increase bomb probability
if (LK.getScore() >= bombThreshold) {
bombProbability = Math.min(0.4, bombProbability + 0.05);
}
}
// Decrease player lives
function decreaseLives() {
lives--;
// Update hearts display
for (var i = 0; i < hearts.length; i++) {
hearts[i].setActive(i < lives);
}
if (lives <= 0) {
gameOver();
}
}
// Game over handling
function gameOver() {
gameRunning = false;
LK.getSound('gameover').play();
LK.clearInterval(spawnTimer);
LK.clearInterval(difficultyTimer);
// Fade out music
LK.playMusic('gameMusic', {
fade: {
start: 0.4,
end: 0,
duration: 1000
}
});
// Show game over screen after a short delay
LK.setTimeout(function () {
LK.showGameOver();
}, 1000);
}
// Handle objects that reach the bottom of the screen
function handleOffscreenObjects() {
for (var i = fallingObjects.length - 1; i >= 0; i--) {
var obj = fallingObjects[i];
if (obj.y > 2732 + 100) {
// Object fell off the bottom of the screen
if (obj.isActive && obj instanceof Banana) {
// Player missed a banana
decreaseLives();
}
obj.destroy();
fallingObjects.splice(i, 1);
}
}
}
// Update the game state every frame
game.update = function () {
if (!gameRunning && lives > 0) {
startGame();
}
if (gameRunning) {
handleOffscreenObjects();
updateScore();
}
};
// Update the score display
function updateScore() {
scoreTxt.setText(LK.getScore().toString());
}
// Start game when loaded
LK.setTimeout(function () {
startGame();
}, 500);
Pixel banana. In-Game asset. High contrast. No shadows
Pixel art Bomb.. In-Game asset. High contrast. No shadows
Pixel art Heart. In-Game asset. High contrast. No shadows
Pixel art Forest background. In-Game asset. High contrast. No shadows
Purple color "+1" in pixels art style . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Simple empty clean pixel art background in brown. In-Game asset. 2d. High contrast. No shadows. Game menu background.
Menu button. Pixel art dark brown.. In-Game asset. 2d. High contrast. No shadows No writing inside