User prompt
In phase 1, the watermelon should drop more seeds according to the damage it has received. But it was limit.
User prompt
Bazı karpuz dilimleri Muzu takip etmeli ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Watermelon slices also come more in phase 2
User prompt
Watermelon Slices also come in phase 2 but are larger, they also come more frequently in both phases but are still rare. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
In the first phase, the watermelon should throw larger watermelon slices than the seeds, but they should throw less seeds, very rarely. Also, they should come from outside the screen. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
The watermelonshould move a bit faster in phase 2.
User prompt
Only 1 potion per phase, no more than that
User prompt
Watermelon must drop at least 1 and at most 2 potions in each phase.
User prompt
The potion should last for 5 seconds, should come less frequently, and should come towards the banana. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
The watermelon very rarely fires a potion attack instead of a seed, which makes the banana's bullets larger and deal 15 damage. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Add Clouds on the Background
User prompt
When the watermelon dies, there should be an animation of the watermelon exploding before the "You win" screen. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
In phase 2, when the watermelon's health reaches 100, more and faster seeds should come, and this should continue until the watermelon dies.
User prompt
Seeds should be bigger on the phase 1 and also bigger on the phase 2
User prompt
Watermelon Should look Different on the Phase 2, so New asset
User prompt
Watermelon should bigger on the phase 2 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
In both phases, the watermelon should be able to move both left and right.
User prompt
There should be an animation when the watermelon moves to the second phase. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When the watermelon dies, it should go to the second phase, where it should have 500 health, and it should shoot bigger and faster bullets.
User prompt
The color change on the health bar should be from right to left instead of from both sides.
User prompt
As the watermelon's health decreases, its health bar should become increasingly white. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Watermelon should have a health bar instead of a text
User prompt
Banana should a little bit bigger
User prompt
Health and Boss Health text should be bigger
User prompt
Watermelon's seed should Makes 20 damage
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Banana = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('banana', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.2
});
var gun = self.attachAsset('gun', {
anchorX: 0,
anchorY: 0.5
});
gun.x = 30;
gun.y = 0;
self.maxHealth = 100;
self.health = self.maxHealth;
self.shootCooldown = 0;
self.invulnerable = false;
self.invulnerableTimer = 0;
self.takeDamage = function (damage) {
if (self.invulnerable) return;
self.health -= damage;
self.invulnerable = true;
self.invulnerableTimer = 60; // 1 second at 60fps
// Flash effect
LK.effects.flashObject(self, 0xFF0000, 500);
LK.getSound('hit').play();
if (self.health <= 0) {
LK.showGameOver();
}
};
self.update = function () {
if (self.shootCooldown > 0) {
self.shootCooldown--;
}
if (self.invulnerable && self.invulnerableTimer > 0) {
self.invulnerableTimer--;
if (self.invulnerableTimer <= 0) {
self.invulnerable = false;
}
}
};
return self;
});
var BananaProjectile = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('bananaProjectile', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.damage = 5;
self.update = function () {
self.x += self.speed;
};
return self;
});
var Cloud = Container.expand(function () {
var self = Container.call(this);
var cloudTypes = ['cloud1', 'cloud2', 'cloud3'];
var cloudType = cloudTypes[Math.floor(Math.random() * cloudTypes.length)];
var graphics = self.attachAsset(cloudType, {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 0.5 + Math.random() * 1.5; // Random speed between 0.5 and 2
self.update = function () {
self.x -= self.speed;
// Reset cloud position when it goes off screen
if (self.x < -200) {
self.x = 2248; // Reset to right side of screen
self.y = Math.random() * 1000 + 200; // Random height
}
};
return self;
});
var WatermelonBoss = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('watermelon', {
anchorX: 0.5,
anchorY: 0.5
});
self.graphics = graphics; // Store reference to graphics for phase switching
self.maxHealth = 500;
self.health = self.maxHealth;
self.attackTimer = 0;
self.attackCooldown = 180; // 3 seconds
self.phase = 1;
self.moveDirection = 1;
self.moveSpeed = 1;
self.takeDamage = function (damage) {
self.health -= damage;
LK.effects.flashObject(self, 0xFF0000, 200);
LK.getSound('bosshit').play();
// Change phase based on health
if (self.health <= self.maxHealth * 0.66 && self.phase === 1) {
self.phase = 2;
self.attackCooldown = 135; // Faster attacks
} else if (self.health <= self.maxHealth * 0.33 && self.phase === 2) {
self.phase = 3;
self.attackCooldown = 90; // Even faster attacks
}
if (self.health <= 0) {
if (self.phase < 4) {
// If not in final phase yet
// Transition to second phase
self.phase = 4; // Mark as second phase
self.maxHealth = 500;
self.health = 500;
self.attackCooldown = 60; // Much faster attacks
// Switch to phase 2 asset
self.removeChild(self.graphics);
self.graphics = self.attachAsset('watermelonPhase2', {
anchorX: 0.5,
anchorY: 0.5
});
// Flash effect for phase transition
LK.effects.flashObject(self, 0x00FF00, 1000);
// Add dramatic animation for phase transition
tween(self, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
// Keep the bigger size in phase 2, don't scale back down
}
});
// Add rotation animation
tween(self, {
rotation: Math.PI * 2
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
self.rotation = 0;
}
});
} else {
// Explosion animation before showing You Win
tween(self, {
scaleX: 3.0,
scaleY: 3.0,
alpha: 0,
rotation: Math.PI * 4
}, {
duration: 1000,
easing: tween.easeOut,
onFinish: function onFinish() {
LK.showYouWin();
}
});
}
}
};
self.seedAttack = function () {
var numSeeds = self.phase === 1 ? 3 : self.phase === 2 ? 5 : self.phase === 3 ? 8 : 10; // More seeds in second phase
for (var i = 0; i < numSeeds; i++) {
var seed = new WatermelonSeed();
seed.x = self.x + (Math.random() - 0.5) * 100;
seed.y = self.y + 50;
var angle = Math.random() * Math.PI * 2;
var baseSpeed = self.phase === 4 ? 5 : 2; // Faster in second phase
var speed = baseSpeed + Math.random() * (self.phase === 4 ? 5 : 3); // Higher speed range in second phase
seed.speedX = Math.cos(angle) * speed;
seed.speedY = Math.sin(angle) * speed;
// Make seeds bigger in phase 1 and even bigger in second phase
if (self.phase === 4) {
seed.scaleX = 2.0;
seed.scaleY = 2.0;
} else {
seed.scaleX = 1.5;
seed.scaleY = 1.5;
}
watermelonSeeds.push(seed);
game.addChild(seed);
}
};
self.update = function () {
// Movement - both vertical and horizontal
self.y += self.moveDirection * self.moveSpeed;
self.x += self.moveDirection * self.moveSpeed * 0.5; // Horizontal movement at half speed
if (self.y <= 300 || self.y >= 2400) {
self.moveDirection *= -1;
}
// Keep boss within horizontal bounds
if (self.x <= 200) {
self.x = 200;
self.moveDirection = Math.abs(self.moveDirection);
} else if (self.x >= 1800) {
self.x = 1800;
self.moveDirection = -Math.abs(self.moveDirection);
}
// Attack logic
self.attackTimer++;
if (self.attackTimer >= self.attackCooldown) {
self.seedAttack();
self.attackTimer = 0;
}
};
return self;
});
var WatermelonSeed = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('watermelonSeed', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = 0;
self.speedY = 0;
self.damage = 20;
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Music
// Sound effects
// Projectile assets
// Character assets
// Game variables
var banana;
var watermelonBoss;
var bananaProjectiles = [];
var watermelonSeeds = [];
var clouds = [];
var dragNode = null;
// Create initial clouds
for (var c = 0; c < 8; c++) {
var cloud = new Cloud();
cloud.x = Math.random() * 2048;
cloud.y = Math.random() * 1000 + 200;
clouds.push(cloud);
game.addChild(cloud);
}
// UI Elements
var healthBar = new Text2('Health: 100', {
size: 80,
fill: 0xFFFFFF
});
healthBar.anchor.set(0, 0);
LK.gui.topLeft.addChild(healthBar);
var bossHealthBar = new Text2('Boss Health: 500', {
size: 80,
fill: 0xFF0000
});
bossHealthBar.anchor.set(0.5, 0);
LK.gui.top.addChild(bossHealthBar);
// Initialize game objects
banana = game.addChild(new Banana());
banana.x = 200;
banana.y = 1366;
watermelonBoss = game.addChild(new WatermelonBoss());
watermelonBoss.x = 1600;
watermelonBoss.y = 1366;
// Event handlers
function handleMove(x, y, obj) {
if (dragNode) {
dragNode.x = x;
dragNode.y = y;
// Keep banana within bounds for horizontal screen
if (dragNode.x < 50) dragNode.x = 50;
if (dragNode.x > 800) dragNode.x = 800;
if (dragNode.y < 200) dragNode.y = 200;
if (dragNode.y > 2532) dragNode.y = 2532;
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
dragNode = banana;
handleMove(x, y, obj);
// Shoot projectile
if (banana.shootCooldown <= 0) {
var projectile = new BananaProjectile();
projectile.x = banana.x + 70;
projectile.y = banana.y;
bananaProjectiles.push(projectile);
game.addChild(projectile);
banana.shootCooldown = 15; // 0.25 seconds
LK.getSound('shoot').play();
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Main game loop
game.update = function () {
// Update UI
healthBar.setText('Health: ' + banana.health);
var phaseText = watermelonBoss.phase === 4 ? ' (Phase 2)' : '';
bossHealthBar.setText('Boss Health: ' + watermelonBoss.health + phaseText);
// Handle banana projectiles
for (var i = bananaProjectiles.length - 1; i >= 0; i--) {
var projectile = bananaProjectiles[i];
// Remove if off screen
if (projectile.x > 2098) {
projectile.destroy();
bananaProjectiles.splice(i, 1);
continue;
}
// Check collision with boss
if (projectile.intersects(watermelonBoss)) {
watermelonBoss.takeDamage(projectile.damage);
projectile.destroy();
bananaProjectiles.splice(i, 1);
continue;
}
}
// Handle watermelon seeds
for (var j = watermelonSeeds.length - 1; j >= 0; j--) {
var seed = watermelonSeeds[j];
// Remove if off screen
if (seed.x < -50 || seed.x > 2098 || seed.y < -50 || seed.y > 2782) {
seed.destroy();
watermelonSeeds.splice(j, 1);
continue;
}
// Check collision with banana
if (seed.intersects(banana)) {
banana.takeDamage(seed.damage);
seed.destroy();
watermelonSeeds.splice(j, 1);
continue;
}
}
// Spawn new clouds occasionally
if (LK.ticks % 600 === 0) {
// Every 10 seconds
var newCloud = new Cloud();
newCloud.x = 2248;
newCloud.y = Math.random() * 1000 + 200;
clouds.push(newCloud);
game.addChild(newCloud);
}
// Clean up clouds that are too far off screen
for (var k = clouds.length - 1; k >= 0; k--) {
var cloud = clouds[k];
if (cloud.x < -300) {
cloud.destroy();
clouds.splice(k, 1);
}
}
};
// Start battle music
LK.playMusic('battle'); ===================================================================
--- original.js
+++ change.js
@@ -62,8 +62,27 @@
self.x += self.speed;
};
return self;
});
+var Cloud = Container.expand(function () {
+ var self = Container.call(this);
+ var cloudTypes = ['cloud1', 'cloud2', 'cloud3'];
+ var cloudType = cloudTypes[Math.floor(Math.random() * cloudTypes.length)];
+ var graphics = self.attachAsset(cloudType, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 0.5 + Math.random() * 1.5; // Random speed between 0.5 and 2
+ self.update = function () {
+ self.x -= self.speed;
+ // Reset cloud position when it goes off screen
+ if (self.x < -200) {
+ self.x = 2248; // Reset to right side of screen
+ self.y = Math.random() * 1000 + 200; // Random height
+ }
+ };
+ return self;
+});
var WatermelonBoss = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('watermelon', {
anchorX: 0.5,
@@ -224,9 +243,18 @@
var banana;
var watermelonBoss;
var bananaProjectiles = [];
var watermelonSeeds = [];
+var clouds = [];
var dragNode = null;
+// Create initial clouds
+for (var c = 0; c < 8; c++) {
+ var cloud = new Cloud();
+ cloud.x = Math.random() * 2048;
+ cloud.y = Math.random() * 1000 + 200;
+ clouds.push(cloud);
+ game.addChild(cloud);
+}
// UI Elements
var healthBar = new Text2('Health: 100', {
size: 80,
fill: 0xFFFFFF
@@ -315,7 +343,24 @@
watermelonSeeds.splice(j, 1);
continue;
}
}
+ // Spawn new clouds occasionally
+ if (LK.ticks % 600 === 0) {
+ // Every 10 seconds
+ var newCloud = new Cloud();
+ newCloud.x = 2248;
+ newCloud.y = Math.random() * 1000 + 200;
+ clouds.push(newCloud);
+ game.addChild(newCloud);
+ }
+ // Clean up clouds that are too far off screen
+ for (var k = clouds.length - 1; k >= 0; k--) {
+ var cloud = clouds[k];
+ if (cloud.x < -300) {
+ cloud.destroy();
+ clouds.splice(k, 1);
+ }
+ }
};
// Start battle music
LK.playMusic('battle');
\ No newline at end of file