User prompt
Please fix the bug: 'Uncaught TypeError: LK.effects.shakeScreen is not a function' in or related to this line: 'LK.effects.shakeScreen(5, 0.5 * 1000); // Shake with magnitude 5 for 0.5 seconds (500ms)' Line Number: 350 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Ekran Titreşim Efekti (Shake) Bomba yediğinde ekran 0.5 saniye titrer. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
muz kombolarını kaldır.
Code edit (1 edits merged)
Please save this source code
User prompt
çürük muzlar neden spawn olmuyor? bu hatayı düzet artık 30dan sonra %100 ihtimalle çürük muz spawn olsun.
Code edit (3 edits merged)
Please save this source code
User prompt
çürük muzlar çıkmıyor çürük muz assetini oyuna ekle ve bomba gibi aynı çürük muzlarıda oyuna ekle.
User prompt
çürük muzlarda bir hata var spawn olmuyorlar. bu hatayı düzelt ve çürük muzların spawmn olmasını sağla
User prompt
çürük muzlar hiç spawn olmuyor bunu düzlet skor 20yi geçtikten sonra %100 spawn olsun
User prompt
muzların düşme ihtimalini %100 yap ve çürük muzları geri ekle
Code edit (2 edits merged)
Please save this source code
User prompt
There is something wrong somewhere, rotten bananas are not spawning. Fix this.
User prompt
Fix the mechanic so that rotten bananas don't spawn after 30 and now they spawn after 20. Do this.
Code edit (2 edits merged)
Please save this source code
User prompt
In the combo system, let's see how many multipliers we are in a purple text when we click on each banana and if we can't click on the banana for 1.5 seconds, let the combo end. Let's do this. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
banana combo system. do this
Code edit (1 edits merged)
Please save this source code
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%.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var FallingItem = Container.expand(function () {
var self = Container.call(this);
self.type = "banana"; // default type
self.speed = 2; // default speed
self.lastY = 0;
self.active = true;
self.graphics = null;
self.init = function (type, speed) {
self.type = type || "banana";
self.speed = speed || 2;
// Remove any existing graphics
if (self.graphics) {
self.removeChild(self.graphics);
}
// Create the appropriate graphics based on type
if (self.type === "banana") {
self.graphics = self.attachAsset('banana', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (self.type === "bomb") {
self.graphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (self.type === "heart") {
self.graphics = self.attachAsset('heart', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (self.type === "rottenBanana") {
self.graphics = self.attachAsset('rottenBanana', {
anchorX: 0.5,
anchorY: 0.5
});
}
// Set initial position
self.x = Math.random() * (2048 - 200) + 100;
self.y = -100;
self.lastY = self.y;
// Interactive for tapping
self.interactive = true;
};
self.update = function () {
if (!self.active) return;
self.lastY = self.y;
self.y += self.speed;
};
self.down = function (x, y, obj) {
if (!self.active) return;
if (self.type === "banana") {
// Scored a point by tapping banana
LK.setScore(LK.getScore() + 1);
LK.getSound('pop').play();
self.remove();
} else if (self.type === "bomb") {
// Lost a life by tapping bomb
LK.getSound('explosion').play();
decreaseLife();
self.remove();
} else if (self.type === "heart") {
// Gained a life by tapping heart
LK.getSound('pop').play();
increaseLife();
self.remove();
} else if (self.type === "rottenBanana") {
// Lost a life by tapping rotten banana
LK.getSound('explosion').play();
decreaseLife();
self.remove();
}
};
self.remove = function () {
self.active = false;
tween(self, {
alpha: 0,
scaleX: 0.3,
scaleY: 0.3
}, {
duration: 200,
onFinish: function onFinish() {
self.destroy();
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
;
// Game constants
var SCREEN_WIDTH = 2048;
var SCREEN_HEIGHT = 2732;
var MAX_LIVES = 3;
var BOMB_THRESHOLD_SCORE = 15;
var SPAWN_INTERVAL_INITIAL = 60; // frames
var MIN_SPAWN_INTERVAL = 20; // frames
var INTERVAL_DECREMENT = 1;
// Game variables
var fallingItems = [];
var lives = MAX_LIVES;
var spawnCounter = 0;
var currentSpawnInterval = SPAWN_INTERVAL_INITIAL;
var currentSpeed = 2;
var isGameOver = false;
var extraHeartSpawned = false;
var extraHeartCaught = false;
// Add background
var background = game.addChild(LK.getAsset('background', {
anchorX: 0,
anchorY: 0
}));
// Initialize score text
var scoreText = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF,
stroke: 0x000000,
strokeThickness: 8,
bold: true
});
scoreText.anchor.set(0.5, 0);
scoreText.x = SCREEN_WIDTH / 2;
scoreText.y = 50;
game.addChild(scoreText);
// Create hearts container
var heartsContainer = new Container();
heartsContainer.x = 50;
heartsContainer.y = 50;
game.addChild(heartsContainer);
// Initialize hearts display
function initLives() {
// Clear existing hearts
while (heartsContainer.children.length > 0) {
heartsContainer.removeChildAt(0);
}
// Add hearts based on current lives
for (var i = 0; i < lives; i++) {
var heart = LK.getAsset('heart', {
anchorX: 0,
anchorY: 0,
x: i * 100,
y: 0
});
heartsContainer.addChild(heart);
}
}
// Function to increase life
function increaseLife() {
if (lives < MAX_LIVES) {
lives++;
initLives();
extraHeartCaught = true;
}
}
// Function to decrease life
function decreaseLife() {
lives--;
initLives();
// Shake the screen
LK.effects.flashScreen(0xff0000, 300);
// Check for game over
if (lives <= 0) {
gameOver();
}
}
// Function to handle game over
function gameOver() {
if (isGameOver) return;
isGameOver = true;
LK.getSound('gameover').play();
LK.effects.flashScreen(0xff0000, 1000);
// Remove all falling items
for (var i = fallingItems.length - 1; i >= 0; i--) {
fallingItems[i].destroy();
}
fallingItems = [];
// Show game over screen
LK.setTimeout(function () {
LK.showGameOver();
}, 1000);
}
// Function to spawn a new falling item
function spawnItem() {
var score = LK.getScore();
var isBomb = score >= BOMB_THRESHOLD_SCORE && Math.random() < 0.3;
var isRottenBanana = score >= 30 && Math.random() < 0.3;
var itemType = "banana";
if (isBomb) {
itemType = "bomb";
} else if (isRottenBanana) {
itemType = "rottenBanana";
}
var item = new FallingItem();
// Use special speed for heart when score > 100 and low health
if (itemType === "heart" && score > 100 && lives === 1) {
item.init(itemType, 16); // Set heart falling speed to 16x
} else {
item.init(itemType, currentSpeed);
}
fallingItems.push(item);
game.addChild(item);
return item;
}
// Update game state each frame
game.update = function () {
if (isGameOver) return;
// Update all falling items
for (var i = fallingItems.length - 1; i >= 0; i--) {
var item = fallingItems[i];
// Check if item has fallen off screen
if (item && item.lastY !== undefined && item.active && item.lastY < SCREEN_HEIGHT && item.y >= SCREEN_HEIGHT) {
if (item.type === "banana" && item.active) {
// Missed a banana - lose a life
decreaseLife();
item.remove();
} else if (item.type === "bomb" && item.active || item.type === "rottenBanana" && item.active) {
// Bomb or rotten banana fell off screen - remove it with no penalty
item.destroy();
fallingItems.splice(i, 1);
}
}
// Remove destroyed items from array
if (!item.active || item.alpha <= 0) {
fallingItems.splice(i, 1);
}
}
// Spawn new items at intervals
spawnCounter++;
// Spawn extra heart when score > 100, only 1 life left, and haven't spawned it yet
var score = LK.getScore();
if (score > 100 && lives === 1 && !extraHeartSpawned && !extraHeartCaught) {
var heartItem = new FallingItem();
heartItem.init("heart", 16); // Set heart falling speed to 16x
fallingItems.push(heartItem);
game.addChild(heartItem);
extraHeartSpawned = true;
}
if (spawnCounter >= currentSpawnInterval) {
spawnItem();
spawnCounter = 0;
// Increase difficulty based on score thresholds
var score = LK.getScore();
// Set speed multiplier based on score thresholds
var speedMultiplier = 1;
if (score >= 200) {
speedMultiplier = 20;
} else if (score >= 190) {
speedMultiplier = 19;
} else if (score >= 180) {
speedMultiplier = 18;
} else if (score >= 170) {
speedMultiplier = 17;
} else if (score >= 160) {
speedMultiplier = 16;
} else if (score >= 150) {
speedMultiplier = 15;
} else if (score >= 140) {
speedMultiplier = 14;
} else if (score >= 130) {
speedMultiplier = 13;
} else if (score >= 120) {
speedMultiplier = 12;
} else if (score >= 110) {
speedMultiplier = 11;
} else if (score >= 100) {
speedMultiplier = 10.5;
} else if (score >= 90) {
speedMultiplier = 10;
} else if (score >= 80) {
speedMultiplier = 9.5;
} else if (score >= 70) {
speedMultiplier = 9;
} else if (score >= 60) {
speedMultiplier = 8.5;
} else if (score >= 50) {
speedMultiplier = 8;
} else if (score >= 40) {
speedMultiplier = 7.5;
} else if (score >= 30) {
speedMultiplier = 7;
} else if (score >= 20) {
speedMultiplier = 6.5;
} else if (score >= 10) {
speedMultiplier = 6;
} else if (score >= 5) {
speedMultiplier = 2;
}
currentSpeed = 2 * speedMultiplier;
currentSpawnInterval = Math.max(MIN_SPAWN_INTERVAL, SPAWN_INTERVAL_INITIAL - score * INTERVAL_DECREMENT);
}
// Update score text
scoreText.setText('Score: ' + LK.getScore());
};
// Initialize the game
function initGame() {
// Reset game variables
lives = MAX_LIVES;
LK.setScore(0);
spawnCounter = 0;
currentSpawnInterval = SPAWN_INTERVAL_INITIAL;
currentSpeed = 2;
isGameOver = false;
extraHeartSpawned = false;
extraHeartCaught = false;
fallingItems = [];
// Initialize UI
initLives();
scoreText.setText('Score: 0');
// Play background music
LK.playMusic('gameMusic');
}
// Start the game
initGame(); ===================================================================
--- original.js
+++ change.js
@@ -5,51 +5,8 @@
/****
* Classes
****/
-var BananaEffect = Container.expand(function () {
- var self = Container.call(this);
- self.init = function (x, y) {
- // Create multiple banana particles
- for (var i = 0; i < 8; i++) {
- var particle = self.attachAsset('banana', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.2,
- scaleY: 0.2,
- alpha: 0.8
- });
- // Calculate angle for particle direction
- var angle = Math.PI * 2 * (i / 8);
- // Position particle
- particle.x = 0;
- particle.y = 0;
- // Calculate target position for the tween
- var targetX = Math.cos(angle) * 100;
- var targetY = Math.sin(angle) * 100;
- // Animate particle
- tween(particle, {
- x: targetX,
- y: targetY,
- alpha: 0,
- rotation: Math.random() * Math.PI * 2,
- scaleX: 0.05,
- scaleY: 0.05
- }, {
- duration: 800 + Math.random() * 400,
- easing: tween.easeOut
- });
- }
- // Set position of the effect
- self.x = x;
- self.y = y;
- // Auto-destroy after all animations complete
- LK.setTimeout(function () {
- self.destroy();
- }, 1500);
- };
- return self;
-});
var FallingItem = Container.expand(function () {
var self = Container.call(this);
self.type = "banana"; // default type
self.speed = 2; // default speed
@@ -92,25 +49,19 @@
// Interactive for tapping
self.interactive = true;
};
self.update = function () {
- if (!self.active) {
- return;
- }
+ if (!self.active) return;
self.lastY = self.y;
self.y += self.speed;
};
self.down = function (x, y, obj) {
- if (!self.active) {
- return;
- }
+ if (!self.active) return;
if (self.type === "banana") {
// Scored a point by tapping banana
LK.setScore(LK.getScore() + 1);
LK.getSound('pop').play();
- // Create banana effect at tap position
- createBananaEffect(self.x, self.y);
- self.remove(false);
+ self.remove();
} else if (self.type === "bomb") {
// Lost a life by tapping bomb
LK.getSound('explosion').play();
decreaseLife();
@@ -126,20 +77,10 @@
decreaseLife();
self.remove();
}
};
- self.remove = function (createSouls) {
+ self.remove = function () {
self.active = false;
- // Create soul effect based on item type, but only if createSouls is not false
- if (createSouls !== false) {
- if (self.type === "banana") {
- createSoulEffect(self.x, self.y, 3);
- } else if (self.type === "heart") {
- createSoulEffect(self.x, self.y, 5);
- } else if (self.type === "bomb" || self.type === "rottenBanana") {
- // No souls for negative items
- }
- }
tween(self, {
alpha: 0,
scaleX: 0.3,
scaleY: 0.3
@@ -151,42 +92,8 @@
});
};
return self;
});
-var Soul = Container.expand(function () {
- var self = Container.call(this);
- self.init = function (x, y) {
- // Create soul graphics
- var soulGraphics = self.attachAsset('heart', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.5,
- scaleY: 0.5,
- alpha: 0.7
- });
- // Set initial position
- self.x = x;
- self.y = y;
- // Randomize direction slightly
- self.targetX = Math.random() * 300 - 150 + x;
- self.targetY = y - 300 - Math.random() * 200; // Always float upward
- // Start the float animation
- tween(self, {
- x: self.targetX,
- y: self.targetY,
- alpha: 0,
- scaleX: 0.1,
- scaleY: 0.1
- }, {
- duration: 1500 + Math.random() * 1000,
- easing: tween.easeOut,
- onFinish: function onFinish() {
- self.destroy();
- }
- });
- };
- return self;
-});
/****
* Initialize Game
****/
@@ -214,9 +121,8 @@
var currentSpeed = 2;
var isGameOver = false;
var extraHeartSpawned = false;
var extraHeartCaught = false;
-var gameStarted = false;
// Add background
var background = game.addChild(LK.getAsset('background', {
anchorX: 0,
anchorY: 0
@@ -232,23 +138,11 @@
scoreText.anchor.set(0.5, 0);
scoreText.x = SCREEN_WIDTH / 2;
scoreText.y = 50;
game.addChild(scoreText);
-// Create click to play text
-var clickToPlayText = new Text2('Click to Start', {
- size: 120,
- fill: 0xFFFFFF,
- stroke: 0x000000,
- strokeThickness: 8,
- bold: true
-});
-clickToPlayText.anchor.set(0.5, 0.5);
-clickToPlayText.x = SCREEN_WIDTH / 2;
-clickToPlayText.y = SCREEN_HEIGHT / 2;
-game.addChild(clickToPlayText);
// Create hearts container
var heartsContainer = new Container();
-heartsContainer.x = 1410;
+heartsContainer.x = 50;
heartsContainer.y = 50;
game.addChild(heartsContainer);
// Initialize hearts display
function initLives() {
@@ -260,59 +154,24 @@
for (var i = 0; i < lives; i++) {
var heart = LK.getAsset('heart', {
anchorX: 0,
anchorY: 0,
- x: i * 190,
+ x: i * 100,
y: 0
});
heartsContainer.addChild(heart);
}
}
-// Function to create floating soul effect
-function createSoulEffect(x, y, count) {
- count = count || 1;
- for (var i = 0; i < count; i++) {
- var soul = new Soul();
- soul.init(x, y);
- game.addChild(soul);
- }
-}
-// Function to create banana effect when banana is clicked
-function createBananaEffect(x, y) {
- var effect = new BananaEffect();
- effect.init(x, y);
- game.addChild(effect);
-}
-// Function to check if a heart is already falling
-function isHeartAlreadyFalling() {
- for (var i = 0; i < fallingItems.length; i++) {
- if (fallingItems[i] && fallingItems[i].type === "heart" && fallingItems[i].active) {
- return true;
- }
- }
- return false;
-}
// Function to increase life
function increaseLife() {
if (lives < MAX_LIVES) {
lives++;
initLives();
- extraHeartCaught = true; // Mark that a heart was caught
+ extraHeartCaught = true;
}
}
// Function to decrease life
function decreaseLife() {
- // Create soul effect at heart position that was lost
- var heartIndex = lives - 1;
- if (heartIndex >= 0 && heartsContainer.children[heartIndex]) {
- var heartPos = heartsContainer.children[heartIndex];
- var globalPos = heartsContainer.toGlobal({
- x: heartPos.x + 50,
- y: heartPos.y + 50
- });
- var gamePos = game.toLocal(globalPos);
- createSoulEffect(gamePos.x, gamePos.y, 7);
- }
lives--;
initLives();
// Shake the screen
LK.effects.flashScreen(0xff0000, 300);
@@ -322,16 +181,12 @@
}
}
// Function to handle game over
function gameOver() {
- if (isGameOver) {
- return;
- }
+ if (isGameOver) return;
isGameOver = true;
- gameStarted = false;
LK.getSound('gameover').play();
LK.effects.flashScreen(0xff0000, 1000);
- // [Bu kısım kaldırıldı] -> createSoulEffect ile kalp efektleri artık çıkmayacak
// Remove all falling items
for (var i = fallingItems.length - 1; i >= 0; i--) {
fallingItems[i].destroy();
}
@@ -339,38 +194,24 @@
// Show game over screen
LK.setTimeout(function () {
LK.showGameOver();
}, 1000);
- // Show click to play text again
- clickToPlayText.visible = true;
}
+// Function to spawn a new falling item
function spawnItem() {
var score = LK.getScore();
var isBomb = score >= BOMB_THRESHOLD_SCORE && Math.random() < 0.3;
var isRottenBanana = score >= 30 && Math.random() < 0.3;
- var isHeart = false;
- if (!isHeartAlreadyFalling()) {
- if (score >= 50 && lives === 1 && !extraHeartSpawned) {
- isHeart = true;
- extraHeartSpawned = true;
- } else if (score >= 70 && lives === 1 && extraHeartSpawned && !extraHeartCaught) {
- isHeart = true;
- }
- }
var itemType = "banana";
- if (isHeart) {
- itemType = "heart";
- } else if (isBomb) {
+ if (isBomb) {
itemType = "bomb";
} else if (isRottenBanana) {
- // Make sure rotten bananas can spawn even if bombs are also possible
itemType = "rottenBanana";
}
var item = new FallingItem();
+ // Use special speed for heart when score > 100 and low health
if (itemType === "heart" && score > 100 && lives === 1) {
- item.init(itemType, 16);
- } else if (itemType === "heart" && score >= 50 && lives === 1) {
- item.init(itemType, 10);
+ item.init(itemType, 16); // Set heart falling speed to 16x
} else {
item.init(itemType, currentSpeed);
}
fallingItems.push(item);
@@ -378,11 +219,9 @@
return item;
}
// Update game state each frame
game.update = function () {
- if (!gameStarted || isGameOver) {
- return;
- }
+ if (isGameOver) return;
// Update all falling items
for (var i = fallingItems.length - 1; i >= 0; i--) {
var item = fallingItems[i];
// Check if item has fallen off screen
@@ -397,17 +236,23 @@
fallingItems.splice(i, 1);
}
}
// Remove destroyed items from array
- if (!item || !item.active || item.alpha <= 0) {
+ if (!item.active || item.alpha <= 0) {
fallingItems.splice(i, 1);
}
}
// Spawn new items at intervals
spawnCounter++;
- // Get current score for difficulty calculations
+ // Spawn extra heart when score > 100, only 1 life left, and haven't spawned it yet
var score = LK.getScore();
- // Hearts will be spawned based on specific conditions in spawnItem function
+ if (score > 100 && lives === 1 && !extraHeartSpawned && !extraHeartCaught) {
+ var heartItem = new FallingItem();
+ heartItem.init("heart", 16); // Set heart falling speed to 16x
+ fallingItems.push(heartItem);
+ game.addChild(heartItem);
+ extraHeartSpawned = true;
+ }
if (spawnCounter >= currentSpawnInterval) {
spawnItem();
spawnCounter = 0;
// Increase difficulty based on score thresholds
@@ -454,9 +299,9 @@
speedMultiplier = 6.5;
} else if (score >= 10) {
speedMultiplier = 6;
} else if (score >= 5) {
- speedMultiplier = 4;
+ speedMultiplier = 2;
}
currentSpeed = 2 * speedMultiplier;
currentSpawnInterval = Math.max(MIN_SPAWN_INTERVAL, SPAWN_INTERVAL_INITIAL - score * INTERVAL_DECREMENT);
}
@@ -471,24 +316,15 @@
spawnCounter = 0;
currentSpawnInterval = SPAWN_INTERVAL_INITIAL;
currentSpeed = 2;
isGameOver = false;
- extraHeartSpawned = false; // Reset heart spawn tracking
- extraHeartCaught = false; // Reset heart catch tracking
+ extraHeartSpawned = false;
+ extraHeartCaught = false;
fallingItems = [];
// Initialize UI
initLives();
scoreText.setText('Score: 0');
// Play background music
LK.playMusic('gameMusic');
}
-// Set up click handler to start game
-game.down = function () {
- if (!gameStarted) {
- gameStarted = true;
- clickToPlayText.visible = false;
- initGame();
- }
-};
-// Initialize but don't start the game yet
-lives = MAX_LIVES;
-initLives();
\ No newline at end of file
+// Start the game
+initGame();
\ No newline at end of file
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