User prompt
The keys should be green when ready to be used and red and small when used and in standby. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
add another button, let it be a restart button, to start from 0
User prompt
Let's delete the boss that comes at the beginning of the 2nd episode
User prompt
After you finish the first part of the final boss, let him come alone before moving on to the second part. If we defeat him, we can move on to the second part.
User prompt
When the atom button is used, enemies will disappear by going up quickly and a moving effect will be left behind. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When you die in the game your score is reset
User prompt
Super and atom keys should not overlap each other, they should be next to each other
User prompt
The boss should come at the end of the first section and before the second section starts.
User prompt
At the end of each level, there will be a boss that is twice as big as the big enemy but moves slower, and its health will be 3 times that of the big monster.
User prompt
The big enemy will come after 10 small enemies appear.
User prompt
Let the health bar be twice as big
User prompt
Special use keys overlapped, slightly separated
User prompt
When you die, the game starts from chapter 1.
User prompt
Large enemies deal 2x more damage than small enemies
User prompt
Let there be a life bar below ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
keys should be reduced by 1/4
User prompt
There is another button under the super button called atom and when it is pressed, all enemies on the screen are deleted but the duration of pressing that button is every 2 minutes. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
The super power button should be 5 times bigger on the left. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
The super power button should kill both big enemies and small enemies in one shot, but the shooting speed of the super power should be slower. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Let the hit damage of the super power be very high, but let's be able to use the super power once every 1 minute
User prompt
There should be a button in the middle left of the screen, when we press it, our bullets will be 10 times bigger and when they hit, they will wipe out the enemies in that area. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Let our main character be 3 times bigger than she is now ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
The health level of the big enemies should be 3 times that of the others and they should change direction and come at us.
User prompt
Kill the enemies in the first section with 1 bullet, and in the second section with 2 bullets, and continue like this towards the other sections.
User prompt
You have to let me change the direction of fire when I shoot.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Bullet = Container.expand(function () {
var self = Container.call(this);
self.isSuper = false;
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 0;
self.velocityY = 0;
self.damage = 1;
self.makeSuper = function () {
self.isSuper = true;
self.removeChild(bulletGraphics);
bulletGraphics = self.attachAsset('superBullet', {
anchorX: 0.5,
anchorY: 0.5
});
// Add glowing effect with tween
tween(bulletGraphics, {
scaleX: 1.2,
scaleY: 1.2,
tint: 0xffff00
}, {
duration: 200,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bulletGraphics, {
scaleX: 1.0,
scaleY: 1.0,
tint: 0xff4444
}, {
duration: 200,
easing: tween.easeInOut
});
}
});
};
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
};
return self;
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 3;
self.maxHealth = 3;
self.speed = 1;
self.points = 10;
self.isGiant = false;
self.velocityX = 0;
self.velocityY = 0;
self.update = function () {
if (player) {
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
// Giant enemies change direction more aggressively
if (self.isGiant) {
// Add some randomness to giant enemy movement to make them more unpredictable
var randomX = (Math.random() - 0.5) * 2;
var randomY = (Math.random() - 0.5) * 2;
self.velocityX = (dx / distance + randomX * 0.3) * self.speed;
self.velocityY = (dy / distance + randomY * 0.3) * self.speed;
} else {
self.velocityX = dx / distance * self.speed;
self.velocityY = dy / distance * self.speed;
}
}
}
self.x += self.velocityX;
self.y += self.velocityY;
};
self.takeDamage = function (damage) {
self.health -= damage;
LK.getSound('enemyHit').play();
// Flash red when hit
tween(enemyGraphics, {
tint: 0xFF0000
}, {
duration: 100,
onFinish: function onFinish() {
tween(enemyGraphics, {
tint: 0xFFFFFF
}, {
duration: 100
});
}
});
if (self.health <= 0) {
self.destroy();
return true;
}
return false;
};
self.makeGiant = function () {
self.isGiant = true;
// Giant enemies have 3 times the health of regular enemies
self.health = wave * 3;
self.maxHealth = self.health;
self.speed = self.speed * 0.7;
self.points = self.points * 4;
// Scale up with tween animation
tween(enemyGraphics, {
scaleX: 2.5,
scaleY: 2.5
}, {
duration: 500,
easing: tween.bounceOut
});
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 100;
self.maxHealth = 100;
self.weapon = {
damage: 1,
fireRate: 10,
name: 'Basic Gun'
};
self.lastShot = 0;
self.shoot = function (targetX, targetY) {
// Super bullets have much slower fire rate
var currentFireRate = superBulletActive ? 60 : self.weapon.fireRate; // 60 ticks = 1 second delay for super bullets
if (LK.ticks - self.lastShot < currentFireRate) return;
var bullet = new Bullet();
bullet.x = self.x;
bullet.y = self.y;
if (superBulletActive) {
bullet.makeSuper();
bullet.damage = superBulletDamage; // Use very high damage for super bullets
} else {
bullet.damage = self.weapon.damage;
}
var dx = targetX - self.x;
var dy = targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
bullet.velocityX = dx / distance * 15;
bullet.velocityY = dy / distance * 15;
bullets.push(bullet);
game.addChild(bullet);
self.lastShot = LK.ticks;
LK.getSound('shoot').play();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a1a
});
/****
* Game Code
****/
// Game state variables
var player;
var enemies = [];
var bullets = [];
var gamePoints = storage.points || 0;
var wave = storage.wave || 1;
var enemiesKilled = 0;
var enemiesInWave = 5;
var waveComplete = false;
var shopOpen = false;
var isMouseDown = false;
var lastMouseX = 0;
var lastMouseY = 0;
var superBulletActive = false;
var superBulletCooldown = 0;
var superBulletDuration = 10000; // 10 seconds
var superBulletCooldownTime = 60000; // 60 seconds (1 minute)
var superBulletDamage = 100; // Very high damage for devastating effect
var atomCooldown = 0;
var atomCooldownTime = 120000; // 120 seconds (2 minutes)
// Weapon shop data - all weapons deal 1 damage for consistent bullet counting
var weapons = [{
name: 'Basic Gun',
damage: 1,
fireRate: 10,
cost: 0
}, {
name: 'Rapid Fire',
damage: 1,
fireRate: 5,
cost: 50
}, {
name: 'Heavy Cannon',
damage: 1,
fireRate: 20,
cost: 100
}, {
name: 'Sniper Rifle',
damage: 1,
fireRate: 30,
cost: 200
}, {
name: 'Plasma Gun',
damage: 1,
fireRate: 8,
cost: 150
}];
// UI Elements
var pointsText = new Text2('Points: 0', {
size: 40,
fill: 0xFFFFFF
});
pointsText.anchor.set(0, 0);
pointsText.x = 120;
pointsText.y = 20;
LK.gui.topLeft.addChild(pointsText);
var waveText = new Text2('Wave: 1', {
size: 40,
fill: 0xFFFFFF
});
waveText.anchor.set(1, 0);
waveText.x = -20;
waveText.y = 20;
LK.gui.topRight.addChild(waveText);
var healthText = new Text2('Health: 100', {
size: 40,
fill: 0xFF4444
});
healthText.anchor.set(0.5, 1);
healthText.y = -80;
LK.gui.bottom.addChild(healthText);
// Life bar background
var lifeBarBackground = LK.getAsset('lifeBarBackground', {
anchorX: 0.5,
anchorY: 0.5
});
lifeBarBackground.x = 0;
lifeBarBackground.y = -40;
LK.gui.bottom.addChild(lifeBarBackground);
// Life bar foreground
var lifeBar = LK.getAsset('lifeBar', {
anchorX: 0,
anchorY: 0.5
});
lifeBar.x = -200; // Start from left edge of background
lifeBar.y = -40;
LK.gui.bottom.addChild(lifeBar);
// Power button in middle left
var powerButton = game.addChild(LK.getAsset('powerButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 120,
y: 1366
}));
// Scale power button to 3.75 times bigger with smooth animation
tween(powerButton, {
scaleX: 3.75,
scaleY: 3.75
}, {
duration: 800,
easing: tween.bounceOut
});
var powerButtonText = new Text2('SUPER', {
size: 24,
fill: 0xFFFFFF
});
powerButtonText.anchor.set(0.5, 0.5);
powerButtonText.x = powerButton.x;
powerButtonText.y = powerButton.y;
game.addChild(powerButtonText);
var powerCooldownText = new Text2('', {
size: 20,
fill: 0xFFFFFF
});
powerCooldownText.anchor.set(0.5, 0.5);
powerCooldownText.x = powerButton.x;
powerCooldownText.y = powerButton.y + 50;
game.addChild(powerCooldownText);
// Atom button under the power button
var atomButton = game.addChild(LK.getAsset('atomButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 120,
y: 1566 // 200 pixels below power button
}));
// Scale atom button to 3.75 times bigger with smooth animation
tween(atomButton, {
scaleX: 3.75,
scaleY: 3.75
}, {
duration: 800,
easing: tween.bounceOut
});
var atomButtonText = new Text2('ATOM', {
size: 24,
fill: 0xFFFFFF
});
atomButtonText.anchor.set(0.5, 0.5);
atomButtonText.x = atomButton.x;
atomButtonText.y = atomButton.y;
game.addChild(atomButtonText);
var atomCooldownText = new Text2('', {
size: 20,
fill: 0xFFFFFF
});
atomCooldownText.anchor.set(0.5, 0.5);
atomCooldownText.x = atomButton.x;
atomCooldownText.y = atomButton.y + 50;
game.addChild(atomCooldownText);
// Shop button
var shopButton = game.addChild(LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 - 120,
y: 2732 - 100
}));
var shopButtonText = new Text2('SHOP', {
size: 32,
fill: 0xFFFFFF
});
shopButtonText.anchor.set(0.5, 0.5);
shopButtonText.x = shopButton.x;
shopButtonText.y = shopButton.y;
game.addChild(shopButtonText);
// Shop UI
var shopContainer = new Container();
shopContainer.visible = false;
game.addChild(shopContainer);
var shopBackground = shopContainer.addChild(LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
scaleX: 6,
scaleY: 9
}));
var shopTitle = new Text2('WEAPON SHOP', {
size: 60,
fill: 0xFFFFFF
});
shopTitle.anchor.set(0.5, 0.5);
shopTitle.x = 1024;
shopTitle.y = 800;
shopContainer.addChild(shopTitle);
var closeShopButton = shopContainer.addChild(LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1800,
scaleX: 1.5,
scaleY: 0.75
}));
var closeShopText = new Text2('CLOSE', {
size: 40,
fill: 0xFFFFFF
});
closeShopText.anchor.set(0.5, 0.5);
closeShopText.x = 1024;
closeShopText.y = 1800;
shopContainer.addChild(closeShopText);
// Weapon shop items
var weaponButtons = [];
var weaponTexts = [];
for (var i = 0; i < weapons.length; i++) {
var weapon = weapons[i];
var buttonY = 1000 + i * 120;
var weaponButton = shopContainer.addChild(LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: buttonY,
scaleX: 2.25,
scaleY: 0.75
}));
weaponButton.weaponIndex = i;
weaponButtons.push(weaponButton);
var weaponText = new Text2(weapon.name + ' - ' + weapon.cost + ' pts', {
size: 32,
fill: 0xFFFFFF
});
weaponText.anchor.set(0.5, 0.5);
weaponText.x = 1024;
weaponText.y = buttonY;
shopContainer.addChild(weaponText);
weaponTexts.push(weaponText);
}
// Initialize player
player = game.addChild(new Player());
player.x = 1024;
player.y = 1366;
// Scale player to 3 times bigger with smooth animation
var playerGraphics = player.children[0];
playerGraphics.scaleX = 1;
playerGraphics.scaleY = 1;
tween(playerGraphics, {
scaleX: 3,
scaleY: 3
}, {
duration: 800,
easing: tween.bounceOut
});
// Game functions
function spawnEnemy() {
var enemy = new Enemy();
// Spawn from random edge
var side = Math.floor(Math.random() * 4);
switch (side) {
case 0:
// Top
enemy.x = Math.random() * 2048;
enemy.y = -50;
break;
case 1:
// Right
enemy.x = 2098;
enemy.y = Math.random() * 2732;
break;
case 2:
// Bottom
enemy.x = Math.random() * 2048;
enemy.y = 2782;
break;
case 3:
// Left
enemy.x = -50;
enemy.y = Math.random() * 2732;
break;
}
// Scale enemy with wave - health equals wave number for bullet count requirement
enemy.health = wave; // Wave 1 = 1 bullet, Wave 2 = 2 bullets, etc.
enemy.maxHealth = enemy.health;
enemy.speed = 1 + wave * 0.1;
enemy.points = 10 + wave * 2;
// 15% chance for giant enemy after wave 3
if (wave >= 3 && Math.random() < 0.15) {
enemy.makeGiant();
}
enemies.push(enemy);
game.addChild(enemy);
// Add spawn animation for all enemies
var enemyGraphics = enemy.children[0];
enemyGraphics.scaleX = 0.1;
enemyGraphics.scaleY = 0.1;
tween(enemyGraphics, {
scaleX: enemy.isGiant ? 2.5 : 1,
scaleY: enemy.isGiant ? 2.5 : 1
}, {
duration: 300,
easing: tween.elasticOut
});
}
function updateUI() {
pointsText.setText('Points: ' + gamePoints);
waveText.setText('Wave: ' + wave);
healthText.setText('Health: ' + player.health);
// Update life bar width based on player health
var healthPercentage = player.health / player.maxHealth;
var newWidth = 400 * healthPercentage;
lifeBar.width = Math.max(0, newWidth);
// Change life bar color based on health percentage
if (healthPercentage > 0.6) {
lifeBar.tint = 0x4caf50; // Green
} else if (healthPercentage > 0.3) {
lifeBar.tint = 0xffc107; // Yellow
} else {
lifeBar.tint = 0xf44336; // Red
}
}
function openShop() {
shopOpen = true;
shopContainer.visible = true;
// Update weapon button states
for (var i = 0; i < weapons.length; i++) {
var weapon = weapons[i];
var canAfford = gamePoints >= weapon.cost;
var owned = player.weapon.name === weapon.name;
var colorHex = owned ? 0x00ff00 : canAfford ? 0xffffff : 0x666666;
var text = weapon.name + ' - ' + weapon.cost + ' pts';
if (owned) text = weapon.name + ' - EQUIPPED';
weaponTexts[i].setText(text);
weaponTexts[i].tint = colorHex;
}
}
function closeShop() {
shopOpen = false;
shopContainer.visible = false;
}
function buyWeapon(weaponIndex) {
var weapon = weapons[weaponIndex];
if (weapon && gamePoints >= weapon.cost && player.weapon.name !== weapon.name) {
gamePoints -= weapon.cost;
player.weapon = {
damage: weapon.damage,
fireRate: weapon.fireRate,
name: weapon.name
};
storage.points = gamePoints;
updateUI();
openShop(); // Refresh shop display
}
}
// Event handlers
shopButton.down = function (x, y, obj) {
openShop();
};
closeShopButton.down = function (x, y, obj) {
closeShop();
};
for (var i = 0; i < weaponButtons.length; i++) {
weaponButtons[i].down = function (x, y, obj) {
buyWeapon(obj.weaponIndex);
};
}
powerButton.down = function (x, y, obj) {
if (superBulletCooldown <= 0 && !superBulletActive) {
superBulletActive = true;
superBulletCooldown = superBulletCooldownTime;
// Visual feedback
tween(powerButton, {
scaleX: 1.2,
scaleY: 1.2,
tint: 0x00ff00
}, {
duration: 200,
easing: tween.bounceOut
});
LK.setTimeout(function () {
superBulletActive = false;
tween(powerButton, {
scaleX: 1.0,
scaleY: 1.0,
tint: 0xffffff
}, {
duration: 200
});
}, superBulletDuration);
}
};
atomButton.down = function (x, y, obj) {
if (atomCooldown <= 0) {
// Destroy all enemies on screen
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
gamePoints += enemy.points;
enemiesKilled++;
LK.getSound('enemyDestroy').play();
enemy.destroy();
enemies.splice(i, 1);
}
atomCooldown = atomCooldownTime;
// Visual feedback
tween(atomButton, {
scaleX: 1.2,
scaleY: 1.2,
tint: 0x00ff00
}, {
duration: 200,
easing: tween.bounceOut
});
LK.setTimeout(function () {
tween(atomButton, {
scaleX: 1.0,
scaleY: 1.0,
tint: 0xffffff
}, {
duration: 200
});
}, 500);
}
};
game.down = function (x, y, obj) {
if (!shopOpen && player) {
// Right click moves player, left click shoots
if (obj.event && obj.event.button === 2) {
// Right click - move player
player.x = x;
player.y = y;
} else {
// Left click or touch - shoot
isMouseDown = true;
lastMouseX = x;
lastMouseY = y;
player.shoot(x, y);
}
}
};
// Spawn initial enemies
for (var i = 0; i < enemiesInWave; i++) {
LK.setTimeout(function () {
spawnEnemy();
}, i * 2000);
}
game.move = function (x, y, obj) {
if (isMouseDown && !shopOpen) {
lastMouseX = x;
lastMouseY = y;
}
};
game.up = function (x, y, obj) {
isMouseDown = false;
};
// Prevent context menu on right click
game.on('rightdown', function (x, y, obj) {
if (obj.event) {
obj.event.preventDefault();
}
});
// Main game loop
game.update = function () {
if (shopOpen) return;
// Continuous firing when mouse is held down
if (isMouseDown && player) {
player.shoot(lastMouseX, lastMouseY);
}
// Update bullets
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
// Check if bullet is off screen
if (bullet.x < -50 || bullet.x > 2098 || bullet.y < -50 || bullet.y > 2782) {
bullet.destroy();
bullets.splice(i, 1);
continue;
}
// Check bullet-enemy collisions
var hitEnemy = false;
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (bullet.intersects(enemy)) {
if (bullet.isSuper) {
// Super bullet area damage - hit all enemies in area
var areaRadius = 200;
for (var k = enemies.length - 1; k >= 0; k--) {
var areaEnemy = enemies[k];
var dx = areaEnemy.x - bullet.x;
var dy = areaEnemy.y - bullet.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance <= areaRadius) {
var destroyed = areaEnemy.takeDamage(bullet.damage);
if (destroyed) {
gamePoints += areaEnemy.points;
enemiesKilled++;
LK.getSound('enemyDestroy').play();
enemies.splice(k, 1);
if (k < j) j--; // Adjust index if we removed an enemy before current
}
}
}
} else {
// Regular bullet single target damage
var destroyed = enemy.takeDamage(bullet.damage);
if (destroyed) {
gamePoints += enemy.points;
enemiesKilled++;
LK.getSound('enemyDestroy').play();
enemies.splice(j, 1);
}
}
bullet.destroy();
bullets.splice(i, 1);
hitEnemy = true;
break;
}
}
if (hitEnemy) continue;
}
// Check enemy-player collisions
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
if (enemy.intersects(player)) {
// Giant enemies deal 2x damage compared to regular enemies
var damage = enemy.isGiant ? 20 : 10;
player.health -= damage;
enemy.destroy();
enemies.splice(i, 1);
if (player.health <= 0) {
// Game over - reset to chapter 1
storage.points = gamePoints;
storage.wave = 1; // Reset to chapter 1 when player dies
LK.showGameOver();
return;
}
}
}
// Check wave completion
if (enemiesKilled >= enemiesInWave && enemies.length === 0 && !waveComplete) {
waveComplete = true;
wave++;
enemiesKilled = 0;
enemiesInWave = Math.min(5 + wave, 15);
// Spawn next wave after delay
LK.setTimeout(function () {
waveComplete = false;
for (var i = 0; i < enemiesInWave; i++) {
LK.setTimeout(function () {
spawnEnemy();
}, i * 1500);
}
}, 3000);
}
// Periodic enemy spawning during wave
if (!waveComplete && enemies.length < Math.min(enemiesInWave, 8)) {
if (Math.random() < 0.01) {
spawnEnemy();
}
}
// Update super bullet system
if (superBulletCooldown > 0) {
superBulletCooldown -= 16.67; // Approximately 1 frame at 60fps
if (superBulletCooldown < 0) superBulletCooldown = 0;
}
// Update atom button system
if (atomCooldown > 0) {
atomCooldown -= 16.67; // Approximately 1 frame at 60fps
if (atomCooldown < 0) atomCooldown = 0;
}
// Update power button UI
if (superBulletActive) {
var remaining = Math.ceil((superBulletDuration - LK.ticks * 16.67) / 1000);
powerButtonText.setText('ACTIVE');
powerCooldownText.setText('');
powerButton.tint = 0x00ff00;
} else if (superBulletCooldown > 0) {
var cooldownSeconds = Math.ceil(superBulletCooldown / 1000);
powerButtonText.setText('SUPER');
powerCooldownText.setText(cooldownSeconds + 's');
powerButton.tint = 0x666666;
} else {
powerButtonText.setText('SUPER');
powerCooldownText.setText('READY');
powerButton.tint = 0xffffff;
}
// Update atom button UI
if (atomCooldown > 0) {
var atomCooldownSeconds = Math.ceil(atomCooldown / 1000);
atomButtonText.setText('ATOM');
atomCooldownText.setText(atomCooldownSeconds + 's');
atomButton.tint = 0x666666;
} else {
atomButtonText.setText('ATOM');
atomCooldownText.setText('READY');
atomButton.tint = 0xffffff;
}
updateUI();
// Save progress
if (LK.ticks % 300 === 0) {
storage.points = gamePoints;
storage.wave = wave;
}
}; ===================================================================
--- original.js
+++ change.js
@@ -689,11 +689,11 @@
player.health -= damage;
enemy.destroy();
enemies.splice(i, 1);
if (player.health <= 0) {
- // Game over
+ // Game over - reset to chapter 1
storage.points = gamePoints;
- storage.wave = wave;
+ storage.wave = 1; // Reset to chapter 1 when player dies
LK.showGameOver();
return;
}
}