User prompt
it doesntttttt
User prompt
Fix health bar initialization to ensure it's green at the start
User prompt
bug : tha bar is not green
User prompt
Update player health bar initialization to show full health at start
User prompt
when starting, the bar should be fully green
User prompt
make that player is full health while starting the game and he have 3 stats of health : Green (full) yellow and red, after red he dies and when player obteins a heart, his health changes to the next stat βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
when we start, the health bar should be full and green and when we touch a laser we loose health and when no health it's game over
User prompt
remove shields after using them
User prompt
make less enemies spawn on a wave
User prompt
make player shoot less lasers per sec
User prompt
add a health bar on the player and a heart that restore a part of the health, it can be obtained while killing a boss
User prompt
bug : level 16-30 should be the enemyCat2 not enemyCat
User prompt
1-15 was GrumpyCat, 16-30 is Maxwell (enemyCat2) and new bosses r boss2. Make 16-30 levels harder than 1-15
User prompt
make the game harder
User prompt
make that boss move slowly to players position and make it throw less lasers
User prompt
make that some enemies throw lasers and boss too and make the first boss has 50 HP and the last one 100HP βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
bug : some enemies doesnt fall
User prompt
When boss comes, play boss music
Code edit (1 edits merged)
Please save this source code
User prompt
Meme Cat Invasion
Initial prompt
Game Title: Meme Cat Invasion Description: A hilarious and slightly terrifying game where you fend off an army of meme cats threatening to take over the world. Can you stop them before itβs too late?
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemyCat', {
anchorX: 0.5,
anchorY: 0.5
});
self.type = 'basic';
self.health = 1;
self.speed = 2;
self.pointValue = 10;
self.isActive = true;
self.movePattern = 'straight';
self.movementTime = 0;
self.direction = 1; // 1 right, -1 left
self.update = function () {
if (self.isActive) {
self.movementTime++;
// Move based on pattern
if (self.movePattern === 'straight') {
self.y += self.speed;
} else if (self.movePattern === 'zigzag') {
self.y += self.speed;
self.x += Math.sin(self.movementTime * 0.05) * 3;
} else if (self.movePattern === 'teleport') {
// Always move down
self.y += self.speed;
// And occasionally teleport horizontally
if (self.movementTime % 120 === 0) {
// Teleport every 2 seconds
self.x = 100 + Math.random() * (2048 - 200);
LK.effects.flashObject(self, 0xffffff, 300);
}
}
// Advanced enemies occasionally shoot lasers with increasing frequency in higher waves
var shootChance = 0.01; // Base chance
if (wave > 15) {
shootChance = 0.015 + (wave - 15) * 0.001; // Increases with each wave after 15
shootChance = Math.min(shootChance, 0.03); // Cap at 3%
}
if ((self.type === 'zigzag' || self.type === 'teleport') && Math.random() < shootChance) {
var laser = new EnemyLaser();
// Adjust laser speed based on wave
if (wave > 15) {
laser.speed = 10 + Math.min(5, Math.floor((wave - 15) / 3));
}
laser.x = self.x;
laser.y = self.y + 30;
enemyLasers.push(laser);
game.addChild(laser);
}
// Remove enemy when it goes off screen
if (self.y > 2732 + 50) {
self.isActive = false;
}
}
};
self.takeDamage = function (damage) {
self.health -= damage;
// Flash the enemy red when hit
LK.effects.flashObject(self, 0xff0000, 300);
if (self.health <= 0) {
// Play explosion sound
LK.getSound('explosion').play();
// Chance to drop power-up (15%)
if (Math.random() < 0.15) {
var powerUp = new PowerUp();
powerUp.x = self.x;
powerUp.y = self.y;
// Randomly choose power-up type
var powerType = Math.random();
if (powerType < 0.5) {
powerUp.setType('spreadshot');
} else if (powerType < 0.8) {
powerUp.setType('shield');
} else {
powerUp.setType('bomb');
}
powerUps.push(powerUp);
game.addChild(powerUp);
}
self.isActive = false;
}
};
self.setType = function (newType) {
self.type = newType;
// Get wave-based difficulty multiplier (increases after wave 15)
var difficultyMult = wave > 15 ? 1.5 : 1;
// First remove any existing graphics
self.removeChildren();
// Add the appropriate graphic based on the wave
var assetType = wave > 15 ? 'enemyCat2' : 'enemyCat';
var enemyGraphics = self.attachAsset(assetType, {
anchorX: 0.5,
anchorY: 0.5
});
// For enemyCat2, apply scaling since it's smaller by default
if (wave > 15) {
enemyGraphics.scale.set(3, 3);
}
if (newType === 'basic') {
enemyGraphics.tint = 0xffcc00;
self.health = Math.ceil(2 * difficultyMult);
self.speed = Math.min(5, 3 * difficultyMult);
self.pointValue = Math.ceil(10 * difficultyMult);
self.movePattern = 'straight';
} else if (newType === 'fast') {
enemyGraphics.tint = 0xff9900;
self.health = Math.ceil(2 * difficultyMult);
self.speed = Math.min(7, 5 * difficultyMult);
self.pointValue = Math.ceil(15 * difficultyMult);
self.movePattern = 'straight';
} else if (newType === 'zigzag') {
enemyGraphics.tint = 0x66cc00;
self.health = Math.ceil(3 * difficultyMult);
self.speed = Math.min(5, 3 * difficultyMult);
self.pointValue = Math.ceil(20 * difficultyMult);
self.movePattern = 'zigzag';
} else if (newType === 'teleport') {
enemyGraphics.tint = 0xcc33ff;
self.health = Math.ceil(4 * difficultyMult);
self.speed = Math.min(4, 2 * difficultyMult);
self.pointValue = Math.ceil(30 * difficultyMult);
self.movePattern = 'teleport';
}
};
return self;
});
var BossCat = Enemy.expand(function () {
var self = Enemy.call(this);
// Remove the previous graphic and add boss graphic
self.removeChildren();
var bossGraphics = self.attachAsset('bossCat', {
anchorX: 0.5,
anchorY: 0.5
});
self.type = 'boss';
self.health = 80; // First boss has 80 HP (increased from 50)
self.speed = 1;
self.pointValue = 200;
self.movePattern = 'boss';
self.phase = 0;
self.shootCooldown = 0;
self.isFinalBoss = false; // Track if this is the final boss
// Override update method
self.update = function () {
if (self.isActive) {
self.movementTime++;
// Boss movement pattern
if (self.phase === 0) {
// Move down to position
self.y += self.speed;
if (self.y >= 300) {
self.phase = 1;
self.movementTime = 0;
}
} else if (self.phase === 1) {
// Move slowly towards player's position
if (player && player.x) {
// Calculate direction to player
var directionX = player.x - self.x;
// Move slowly towards player (0.5% of the distance per frame)
self.x += directionX * 0.005;
}
// Add slight vertical movement
self.y += Math.sin(self.movementTime * 0.01) * 1;
// Phase transition based on health percentage
var healthPercent = self.isFinalBoss ? self.health / 100 : self.health / 50;
if (healthPercent <= 0.5 && self.phase < 2) {
self.phase = 2;
self.speed = 1.5;
LK.effects.flashObject(self, 0xff0000, 1000);
}
} else if (self.phase === 2) {
// Move towards player faster in aggressive phase
if (player && player.x) {
var directionX = player.x - self.x;
// Move faster towards player (1% of the distance per frame)
self.x += directionX * 0.01;
}
// Add some vertical movement
self.y += Math.sin(self.movementTime * 0.02) * 2;
}
// Boss shooting logic
self.shootCooldown--;
if (self.shootCooldown <= 0) {
// Shoot pattern based on phase
if (self.phase === 1) {
// Single shot during phase 1, less frequent
self.shootLaser();
self.shootCooldown = 180; // 3 seconds (doubled from original)
} else if (self.phase === 2) {
// Double shot during phase 2, less frequent
self.shootLaser();
self.shootLaser(-30, 0.3);
self.shootCooldown = 120; // 2 seconds (doubled from original)
}
}
}
};
// Boss shooting method
self.shootLaser = function (offsetX, rotation) {
offsetX = offsetX || 0;
rotation = rotation || 0;
var laser = new EnemyLaser();
laser.x = self.x + offsetX;
laser.y = self.y + 100;
if (rotation !== 0) {
laser.rotation = rotation;
}
enemyLasers.push(laser);
game.addChild(laser);
};
// Set boss as final boss
self.setAsFinalBoss = function () {
self.isFinalBoss = true;
self.health = 150; // Final boss has 150 HP (increased from 100)
self.pointValue = 500;
tween(bossGraphics, {
tint: 0xff0000
}, {
duration: 1000
});
};
// Override takeDamage to show health
var originalTakeDamage = self.takeDamage;
self.takeDamage = function (damage) {
originalTakeDamage.call(self, damage);
// Update boss health display
if (bossHealthText) {
bossHealthText.setText("Boss HP: " + self.health);
}
// Drop heart power-up when boss is defeated
if (self.health <= 0) {
// 100% chance to drop heart from boss
var heart = new PowerUp();
heart.x = self.x;
heart.y = self.y;
heart.setType('heart');
powerUps.push(heart);
game.addChild(heart);
}
};
return self;
});
var Boss2 = BossCat.expand(function () {
var self = BossCat.call(this);
// Replace boss graphic with new boss
self.removeChildren();
var bossGraphics = self.attachAsset('enemyCat2', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 3
});
self.type = 'boss2';
self.health = 200; // Second boss has 200 HP by default
self.speed = 1.5;
self.pointValue = 300;
self.movementTime = 0;
self.attackPattern = 0;
self.attackTimer = 0;
// Override update method
var originalUpdate = self.update;
self.update = function () {
if (self.isActive) {
self.movementTime++;
self.attackTimer++;
// Boss2 movement pattern
if (self.phase === 0) {
// Move down to position
self.y += self.speed;
if (self.y >= 350) {
self.phase = 1;
self.movementTime = 0;
}
} else if (self.phase === 1) {
// More complex movement
self.x += Math.sin(self.movementTime * 0.02) * 3;
self.y += Math.cos(self.movementTime * 0.01) * 2;
// Phase transition based on health percentage
var healthPercent = self.isFinalBoss ? self.health / 250 : self.health / 200;
if (healthPercent <= 0.5 && self.phase < 2) {
self.phase = 2;
self.speed = 2;
self.attackPattern = 1;
LK.effects.flashObject(self, 0xff0000, 1000);
}
} else if (self.phase === 2) {
// More aggressive pattern
self.x += Math.sin(self.movementTime * 0.03) * 5;
self.y += Math.sin(self.movementTime * 0.02) * 3;
// Occasionally teleport
if (self.movementTime % 180 === 0) {
self.x = 400 + Math.random() * (2048 - 800);
LK.effects.flashObject(self, 0xffffff, 300);
}
}
// Boss2 shooting logic
self.shootCooldown--;
if (self.shootCooldown <= 0) {
if (self.phase === 1) {
// Triple shot pattern
self.shootLaser();
self.shootLaser(-50, -0.2);
self.shootLaser(50, 0.2);
self.shootCooldown = 150;
} else if (self.phase === 2) {
// More complex attack patterns
if (self.attackPattern === 0) {
// Spiral pattern
for (var i = 0; i < 6; i++) {
var angle = self.attackTimer * 0.01 + i * Math.PI / 3;
var offsetX = Math.cos(angle) * 80;
var offsetY = Math.sin(angle) * 80;
self.shootLaser(offsetX, angle * 0.2);
}
self.shootCooldown = 240;
self.attackPattern = 1;
} else {
// Targeted shots
if (player && player.x) {
var directionX = player.x - self.x;
var angle = Math.atan2(player.y - self.y, directionX);
self.shootLaser(0, angle * 0.3);
self.shootLaser(-30, angle * 0.25);
self.shootLaser(30, angle * 0.35);
}
self.shootCooldown = 180;
self.attackPattern = 0;
}
}
}
}
};
// Set boss as final boss
self.setAsFinalBoss = function () {
self.isFinalBoss = true;
self.health = 250; // Final boss2 has 250 HP
self.pointValue = 800;
tween(bossGraphics, {
tint: 0xff3300
}, {
duration: 1000
});
};
// Override takeDamage to drop heart
var originalTakeDamage = self.takeDamage;
self.takeDamage = function (damage) {
originalTakeDamage.call(self, damage);
// Drop heart power-up when boss is defeated
if (self.health <= 0) {
// 100% chance to drop heart from boss
var heart = new PowerUp();
heart.x = self.x;
heart.y = self.y;
heart.setType('heart');
powerUps.push(heart);
game.addChild(heart);
}
};
return self;
});
var EnemyLaser = Container.expand(function () {
var self = Container.call(this);
var laserGraphics = self.attachAsset('laser', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xff6600
});
self.speed = 10; // Increased from 8
self.damage = 1;
self.isActive = true;
self.update = function () {
if (self.isActive) {
self.y += self.speed;
// Remove laser when it goes off screen
if (self.y > 2732 + 50) {
self.isActive = false;
}
}
};
return self;
});
var Laser = Container.expand(function () {
var self = Container.call(this);
var laserGraphics = self.attachAsset('laser', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -15;
self.damage = 1;
self.isActive = true;
self.update = function () {
if (self.isActive) {
self.y += self.speed;
// Remove laser when it goes off screen
if (self.y < -50) {
self.isActive = false;
}
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.shootCooldown = 0;
self.cooldownTime = 30; // Frames between shots (increased from 15)
self.hasShield = false;
self.hasSpreadshot = false;
self.spreadDuration = 0;
self.shield = null;
self.maxHealth = 100;
self.health = self.maxHealth; // Starting with full health
// Define health state thresholds
self.healthStateThresholds = {
green: 0.66,
// Above 66% is green (full health)
yellow: 0.33 // Above 33% is yellow, below is red
};
self.update = function () {
// Decrease cooldown
if (self.shootCooldown > 0) {
self.shootCooldown--;
}
// Decrease spreadshot duration
if (self.hasSpreadshot) {
self.spreadDuration--;
if (self.spreadDuration <= 0) {
self.hasSpreadshot = false;
}
}
// Update health bar position if it exists
if (healthBar) {
healthBar.x = self.x;
healthBar.y = self.y + 100;
healthBarFill.scale.x = self.health / self.maxHealth;
}
};
self.shoot = function () {
if (self.shootCooldown <= 0) {
if (self.hasSpreadshot) {
// Create spread shot (3 lasers)
var centerLaser = new Laser();
centerLaser.x = self.x;
centerLaser.y = self.y - 40;
lasers.push(centerLaser);
game.addChild(centerLaser);
var leftLaser = new Laser();
leftLaser.x = self.x - 30;
leftLaser.y = self.y - 30;
leftLaser.rotation = -0.3;
lasers.push(leftLaser);
game.addChild(leftLaser);
var rightLaser = new Laser();
rightLaser.x = self.x + 30;
rightLaser.y = self.y - 30;
rightLaser.rotation = 0.3;
lasers.push(rightLaser);
game.addChild(rightLaser);
} else {
// Create single laser
var laser = new Laser();
laser.x = self.x;
laser.y = self.y - 40;
lasers.push(laser);
game.addChild(laser);
}
LK.getSound('shoot').play();
self.shootCooldown = self.cooldownTime;
}
};
self.activateShield = function () {
// Remove existing shield if there is one
if (self.shield && self.shield.isActive) {
self.shield.isActive = false;
game.removeChild(self.shield);
}
// Create new shield
self.hasShield = true;
self.shield = new Shield();
self.shield.x = self.x;
self.shield.y = self.y;
game.addChild(self.shield);
return self.shield;
};
self.activateSpreadshot = function () {
self.hasSpreadshot = true;
self.spreadDuration = 180; // 3 seconds at 60fps (reduced from 5 seconds)
};
self.activateBomb = function () {
// Destroy all enemies on screen
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
if (enemy.isActive) {
enemy.takeDamage(999); // Instant kill
LK.setScore(LK.getScore() + enemy.pointValue);
}
}
// Visual effect for bomb
LK.effects.flashScreen(0xff0000, 500);
};
self.takeDamage = function (damage) {
// Store previous health percentage to detect state transitions
var prevHealthPercent = self.health / self.maxHealth;
self.health -= damage;
// Flash the player red when hit
LK.effects.flashObject(self, 0xff0000, 300);
// Update health bar
if (healthBarFill) {
healthBarFill.scale.x = Math.max(0, self.health / self.maxHealth);
// Get new health percentage
var healthPercent = self.health / self.maxHealth;
// Change health bar color based on percentage
if (healthPercent > 0.66) {
healthBarFill.tint = 0x00ff00; // Green for high health
} else if (healthPercent > 0.33) {
healthBarFill.tint = 0xffcc00; // Yellow/orange for medium health
} else {
healthBarFill.tint = 0xff0000; // Red for low health
}
// Check for transition between health states
if (prevHealthPercent > 0.66 && healthPercent <= 0.66 || prevHealthPercent > 0.33 && healthPercent <= 0.33) {
// Visual effect for health state degradation
tween(healthBarFill, {
alpha: 0.2
}, {
duration: 300,
onFinish: function onFinish() {
tween(healthBarFill, {
alpha: 1
}, {
duration: 300
});
}
});
}
}
// Check if player is dead
if (self.health <= 0) {
gameActive = false;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
return self.health <= 0; // Return true if player died
};
self.heal = function (amount) {
// Store previous health percentage to detect state transitions
var prevHealthPercent = self.health / self.maxHealth;
self.health = Math.min(self.maxHealth, self.health + amount);
// Update health bar
if (healthBarFill) {
healthBarFill.scale.x = self.health / self.maxHealth;
// Get new health percentage
var healthPercent = self.health / self.maxHealth;
// Change health bar color based on percentage
if (healthPercent > 0.66) {
healthBarFill.tint = 0x00ff00; // Green for high health
} else if (healthPercent > 0.33) {
healthBarFill.tint = 0xffcc00; // Yellow/orange for medium health
} else {
healthBarFill.tint = 0xff0000; // Red for low health
}
// Check for transition between health states
if (prevHealthPercent <= 0.33 && healthPercent > 0.33 || prevHealthPercent <= 0.66 && healthPercent > 0.66) {
// Visual effect for health state improvement
tween(healthBarFill, {
alpha: 0.2
}, {
duration: 300,
onFinish: function onFinish() {
tween(healthBarFill, {
alpha: 1
}, {
duration: 300
});
}
});
}
}
// Visual healing effect
LK.effects.flashObject(self, 0x00ff00, 300);
};
return self;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('powerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.type = 'spreadshot'; // Default type
self.speed = 3;
self.isActive = true;
self.update = function () {
if (self.isActive) {
self.y += self.speed;
// Rotate the power-up for visual effect
powerUpGraphics.rotation += 0.05;
// Remove power-up when it goes off screen
if (self.y > 2732 + 50) {
self.isActive = false;
}
}
};
self.setType = function (newType) {
self.type = newType;
// Change appearance based on type
if (newType === 'spreadshot') {
powerUpGraphics.tint = 0xff9900;
} else if (newType === 'shield') {
powerUpGraphics.tint = 0x33ccff;
} else if (newType === 'bomb') {
powerUpGraphics.tint = 0xff3300;
} else if (newType === 'heart') {
powerUpGraphics.tint = 0xff0066;
}
};
return self;
});
var Shield = Container.expand(function () {
var self = Container.call(this);
var shieldGraphics = self.attachAsset('shield', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.5
});
self.duration = 3000; // Shield lasts 3 seconds (reduced from 5)
self.timeLeft = self.duration;
self.isActive = true;
self.update = function () {
if (self.isActive) {
self.timeLeft -= 1000 / 60; // Decrease time left (60 fps)
// Fade out as shield expires
shieldGraphics.alpha = 0.2 + self.timeLeft / self.duration * 0.5;
// Rotate the shield for visual effect
shieldGraphics.rotation += 0.01;
// Deactivate shield when time runs out
if (self.timeLeft <= 0) {
self.isActive = false;
// Remove shield reference from player
if (player) {
player.hasShield = false;
player.shield = null;
}
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000033
});
/****
* Game Code
****/
// Game state variables
var player;
var lasers = [];
var enemyLasers = [];
var enemies = [];
var powerUps = [];
var wave = 1;
var enemiesInWave = 5;
var enemiesSpawned = 0;
var spawnCooldown = 0;
var gameActive = true;
var bossWave = false;
var bossHealthText;
var healthBar;
var healthBarBg;
var healthBarFill;
// UI elements
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.setText("Score: " + LK.getScore());
scoreTxt.anchor.set(0, 0);
LK.gui.topRight.addChild(scoreTxt);
var waveTxt = new Text2('Wave: 1', {
size: 80,
fill: 0xFFFFFF
});
waveTxt.anchor.set(1, 0);
LK.gui.topLeft.addChild(waveTxt);
// Position it away from the top left corner (reserved for menu icon)
waveTxt.x = 250;
// Create player
player = new Player();
player.x = 2048 / 2;
player.y = 2732 - 200;
game.addChild(player);
// Create health bar
healthBar = new Container();
healthBarBg = LK.getAsset('laser', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x444444,
scaleX: 10,
scaleY: 0.5
});
healthBarFill = LK.getAsset('laser', {
anchorX: 0,
// Anchor at the left edge for scaling from left to right
anchorY: 0.5,
// tint: 0x00ff00, // Tint will be set explicitly after creation
scaleX: 10,
scaleY: 0.5 //{6p} // Base height scale factor (visual size)
});
healthBarFill.tint = 0x00ff00; // Explicitly set tint to green for full health
healthBarFill.x = -healthBarBg.width / 2; // Position fill bar's left edge at the background's left edge
// Ensure bar scale correctly represents 100% health at the start
healthBarFill.scale.x = 1; // Use scale.x = 1 to represent 100% health fill (relative to its base scaleX)
// Set initial animation for health bar to draw player's attention
tween(healthBarFill, {
alpha: 0.5
}, {
duration: 500,
onFinish: function onFinish() {
tween(healthBarFill, {
alpha: 1
}, {
duration: 500
});
}
});
healthBar.addChild(healthBarBg);
healthBar.addChild(healthBarFill);
healthBar.x = player.x;
healthBar.y = player.y + 100;
game.addChild(healthBar);
// Start background music
LK.playMusic('gameMusic');
// Game input handlers
game.down = function (x, y, obj) {
// Shoot when tapping anywhere
player.shoot();
};
game.move = function (x, y, obj) {
// Move player horizontally (keep vertical position fixed)
if (gameActive) {
player.x = x;
// Keep player within game bounds
if (player.x < 75) {
player.x = 75;
}
if (player.x > 2048 - 75) {
player.x = 2048 - 75;
}
// Update shield position if active
if (player.shield && player.shield.isActive) {
player.shield.x = player.x;
player.shield.y = player.y;
}
}
};
// Spawn enemies
function spawnEnemy() {
var enemy;
if (bossWave) {
// Use Boss2 for waves 20, 25, and 30
if (wave >= 20 && wave % 5 === 0) {
enemy = new Boss2();
enemy.x = 2048 / 2;
enemy.y = -200;
// If this is the final boss (wave 30), set it to have higher HP
if (wave === 30) {
enemy.setAsFinalBoss();
}
} else {
enemy = new BossCat();
enemy.x = 2048 / 2;
enemy.y = -200;
// If this is the final boss of the first stage (wave 15), set it to have higher HP
if (wave === 15) {
enemy.setAsFinalBoss();
}
}
// Play boss music when boss appears
LK.getSound('boss').play();
// Create boss health display
bossHealthText = new Text2("Boss HP: " + enemy.health, {
size: 60,
fill: 0xFF6600
});
bossHealthText.anchor.set(0.5, 0);
bossHealthText.y = 150;
LK.gui.top.addChild(bossHealthText);
} else {
enemy = new Enemy();
enemy.x = 100 + Math.random() * (2048 - 200);
enemy.y = -100;
// Set random enemy type based on current wave
var typeRoll = Math.random();
if (wave <= 2) {
// Waves 1-2: Only basic enemies
enemy.setType('basic');
} else if (wave <= 4) {
// Waves 3-4: Basic and fast enemies
if (typeRoll < 0.6) {
enemy.setType('basic');
} else {
enemy.setType('fast');
}
} else if (wave <= 6) {
// Waves 5-6: Add zigzag enemies
if (typeRoll < 0.4) {
enemy.setType('basic');
} else if (typeRoll < 0.7) {
enemy.setType('fast');
} else {
enemy.setType('zigzag');
}
} else if (wave <= 15) {
// Waves 7-15: All enemy types
if (typeRoll < 0.3) {
enemy.setType('basic');
} else if (typeRoll < 0.5) {
enemy.setType('fast');
} else if (typeRoll < 0.8) {
enemy.setType('zigzag');
} else {
enemy.setType('teleport');
}
} else {
// Waves 16-30: Harder distribution with fewer basic enemies
if (typeRoll < 0.15) {
enemy.setType('basic');
} else if (typeRoll < 0.4) {
enemy.setType('fast');
} else if (typeRoll < 0.7) {
enemy.setType('zigzag');
} else {
enemy.setType('teleport');
}
}
}
enemies.push(enemy);
game.addChild(enemy);
enemiesSpawned++;
}
// Main game update loop
game.update = function () {
if (!gameActive) {
return;
}
// Update player
player.update();
// Update shield if active
if (player.shield && player.shield.isActive) {
player.shield.update();
if (!player.shield.isActive) {
player.hasShield = false;
game.removeChild(player.shield);
player.shield = null;
}
}
// Handle enemy spawning
if (spawnCooldown <= 0) {
if (enemiesSpawned < enemiesInWave) {
spawnEnemy();
// Cooldown between spawns
if (bossWave) {
spawnCooldown = 1; // Boss spawns immediately
} else {
spawnCooldown = 60; // 1 second between normal enemy spawns
}
}
} else {
spawnCooldown--;
}
// Update lasers and check for collisions
for (var i = lasers.length - 1; i >= 0; i--) {
var laser = lasers[i];
laser.update();
if (!laser.isActive) {
game.removeChild(laser);
lasers.splice(i, 1);
continue;
}
// Check for collisions with enemies
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (enemy.isActive && laser.isActive && laser.intersects(enemy)) {
enemy.takeDamage(laser.damage);
laser.isActive = false;
if (!enemy.isActive) {
LK.setScore(LK.getScore() + enemy.pointValue);
scoreTxt.setText("Score: " + LK.getScore());
game.removeChild(enemy);
enemies.splice(j, 1);
}
break;
}
}
}
// Update enemy lasers and check for collisions with player
for (var el = enemyLasers.length - 1; el >= 0; el--) {
var enemyLaser = enemyLasers[el];
enemyLaser.update();
if (!enemyLaser.isActive) {
game.removeChild(enemyLaser);
enemyLasers.splice(el, 1);
continue;
}
// Check for collision with player
if (enemyLaser.intersects(player)) {
// If player has shield, block the laser
if (player.hasShield) {
enemyLaser.isActive = false;
game.removeChild(enemyLaser);
enemyLasers.splice(el, 1);
// Flash shield to show impact
if (player.shield) {
LK.effects.flashObject(player.shield, 0xffff00, 300);
}
} else {
// Player takes damage from laser
var laserDamage = 20;
player.takeDamage(laserDamage);
enemyLaser.isActive = false;
game.removeChild(enemyLaser);
enemyLasers.splice(el, 1);
if (!gameActive) {
return;
} // Return if player died
}
}
}
// Update enemies
var activeEnemies = 0;
for (var k = enemies.length - 1; k >= 0; k--) {
var enemy = enemies[k];
enemy.update();
if (!enemy.isActive) {
game.removeChild(enemy);
enemies.splice(k, 1);
continue;
}
activeEnemies++;
// Check collision with player
if (enemy.intersects(player)) {
if (player.hasShield) {
// Shield absorbs collision damage
if (player.shield) {
LK.effects.flashObject(player.shield, 0xffff00, 300);
}
} else {
// Player takes damage from collision
var collisionDamage = 30; // Reduced from 50 to make it less punishing
player.takeDamage(collisionDamage);
if (!gameActive) {
return;
} // Return if player died
}
}
}
// Update power-ups
for (var l = powerUps.length - 1; l >= 0; l--) {
var powerUp = powerUps[l];
powerUp.update();
if (!powerUp.isActive) {
game.removeChild(powerUp);
powerUps.splice(l, 1);
continue;
}
// Check collision with player
if (powerUp.intersects(player)) {
// Apply power-up effect
if (powerUp.type === 'spreadshot') {
player.activateSpreadshot();
} else if (powerUp.type === 'shield') {
player.activateShield();
} else if (powerUp.type === 'bomb') {
player.activateBomb();
} else if (powerUp.type === 'heart') {
player.heal(50); // Restore 50 health points
}
LK.getSound('powerup').play();
powerUp.isActive = false;
game.removeChild(powerUp);
powerUps.splice(l, 1);
}
}
// Check if wave is complete
if (enemiesSpawned >= enemiesInWave && activeEnemies === 0) {
// Wave complete, start next wave
wave++;
waveTxt.setText("Wave: " + wave);
// Every 5th wave is a boss wave
if (wave % 5 === 0) {
bossWave = true;
enemiesInWave = 1;
} else {
bossWave = false;
// Reduced enemies per wave to make the game easier
enemiesInWave = 5 + Math.floor(wave * 1.5);
// Remove boss health display if it exists
if (bossHealthText) {
LK.gui.top.removeChild(bossHealthText);
bossHealthText = null;
}
}
enemiesSpawned = 0;
spawnCooldown = 120; // 2 second delay between waves
// Win condition - player has survived 30 waves
if (wave > 30) {
LK.showYouWin();
return;
}
}
// Auto fire if player holds down finger (reduced frequency)
if (LK.ticks % 30 === 0) {
player.shoot();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -720,14 +720,13 @@
healthBarFill = LK.getAsset('laser', {
anchorX: 0,
// Anchor at the left edge for scaling from left to right
anchorY: 0.5,
- tint: 0x00ff00,
- // Start with green tint for full health
+ // tint: 0x00ff00, // Tint will be set explicitly after creation
scaleX: 10,
- //{6o} // Base width scale factor (visual size)
scaleY: 0.5 //{6p} // Base height scale factor (visual size)
});
+healthBarFill.tint = 0x00ff00; // Explicitly set tint to green for full health
healthBarFill.x = -healthBarBg.width / 2; // Position fill bar's left edge at the background's left edge
// Ensure bar scale correctly represents 100% health at the start
healthBarFill.scale.x = 1; // Use scale.x = 1 to represent 100% health fill (relative to its base scaleX)
// Set initial animation for health bar to draw player's attention
explosion π₯. In-Game asset. 2d. High contrast. No shadows
a cat head. In-Game asset. 2d. High contrast
make this cat expression goes silly but angry
2 cucumbers inside a glass bubble. In-Game asset. 2d. High contrast. No shadows
a shield inside a glass bubble. In-Game asset. 2d. High contrast. No shadows
an explosion inside a glass bubble. In-Game asset. 2d. High contrast. No shadows
a heart inside a glass bubble. In-Game asset. 2d. High contrast. No shadows