User prompt
make new enemy spawn condition to false but keep the codes we will use it in future
User prompt
can you put that to the codes
User prompt
decrease newenemy spawn rate to %1
User prompt
make newenemy spawn rate once every 100 seconds
User prompt
make newenemy spawn rate 1 per minute
User prompt
make them spawn in every once in 50 score
User prompt
make rareenemy spawn rate %10
User prompt
make new enemy spawnrate %0.5
User prompt
make new enemy bigger
User prompt
make newenemy spawn rate back to normal
User prompt
make newenemy spawn rate %0.5
User prompt
and while player has protection if player gets hit remove the symbol on top
User prompt
if player catch hpbuff give player protection for 1 laser shot
User prompt
if player catchs hpbuff give another life point to player
User prompt
if player catchs hpbuff symbol make player hp 1
User prompt
make it 1
User prompt
move it to top left
User prompt
it still spawning on same place as score
User prompt
more left
User prompt
bring symbol to left
User prompt
make that symbol spawn on top left on screen and use hpbuff symbol
User prompt
if player catchs it put a symbol on top of screen use a box
User prompt
make hpbuff catchable by player
User prompt
when player kills this newenemy spawn hpbuff asset make it move down
User prompt
add newenemy to game use box
/****
* Classes
****/
// Boss class
// Boss class
var Boss = Container.expand(function () {
var self = Container.call(this);
var bossGraphics = self.attachAsset('boss', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
self.speed = 2;
self.horizontalSpeed = 2;
self.health = 100;
// Define shootDeathLaser function here
self.shotCount = 0; // Initialize shot counter
self.shootDeathLaser = function () {
// Shake effect for 2 seconds
var shakeDuration = 120; // 2 seconds at 60 FPS
var shakeIntensity = 10;
var shakeCount = 0;
var originalX = self.x;
var originalY = self.y;
var shakeInterval = LK.setInterval(function () {
if (shakeCount < shakeDuration) {
self.x = originalX + (Math.random() - 0.5) * shakeIntensity;
self.y = originalY + (Math.random() - 0.5) * shakeIntensity;
shakeCount++;
} else {
LK.clearInterval(shakeInterval);
self.x = originalX;
self.y = originalY;
// Shoot death lasers after shaking
var deathLaser1 = new DeathLaser(self.x - bossGraphics.width * 0.2, self.y + bossGraphics.height * 0.75);
var deathLaser2 = new DeathLaser(self.x + bossGraphics.width * 0.2, self.y + bossGraphics.height * 0.75);
game.addChild(deathLaser1);
game.addChild(deathLaser2);
enemyLasers.push(deathLaser1);
enemyLasers.push(deathLaser2);
// Increment shot counter
self.shotCount++;
// Relocate boss after 6 shots
if (self.shotCount >= 6) {
self.shotCount = 0; // Reset shot counter
self.x = Math.random() * (2048 - bossGraphics.width * 1.5) + bossGraphics.width * 0.75;
self.y = Math.random() * (2732 / 3 - bossGraphics.height * 1.5) + bossGraphics.height * 0.75;
}
// Resume spawning enemies
self.resumeEnemySpawning();
}
}, 1000 / 60); // 60 FPS
};
self.update = function () {
if (self.y < 2732 / 3 - bossGraphics.height / 4) {
self.y += self.speed;
} else {
self.x += self.horizontalSpeed;
if (self.x > 2048 - bossGraphics.width * 0.75 || self.x < bossGraphics.width * 0.75) {
self.horizontalSpeed = -self.horizontalSpeed;
}
// Boss shoots death laser if health is <= 5
if (self.health <= 50 && LK.ticks % 30 == 0) {
self.shootDeathLaser();
}
}
};
self.shoot = function () {
if (self.health <= 50) {
return; // Stop shooting normal lasers if health is 5 or less
}
// Center laser
var centerLaser = new EnemyLaser(self.x, self.y + bossGraphics.height * 0.75);
game.addChild(centerLaser);
enemyLasers.push(centerLaser);
// Right side laser
var rightLaser = new EnemyLaser(self.x + bossGraphics.width * 0.3, self.y + bossGraphics.height * 0.75);
game.addChild(rightLaser);
enemyLasers.push(rightLaser);
// Left side laser
var leftLaser = new EnemyLaser(self.x - bossGraphics.width * 0.3, self.y + bossGraphics.height * 0.75);
game.addChild(leftLaser);
enemyLasers.push(leftLaser);
};
});
var DeathLaser = Container.expand(function (x, y) {
var self = Container.call(this);
var deathLaserGraphics = self.attachAsset('deathlaser', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
self.x = x;
self.y = y;
self.speed = 20;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
});
// EnemyLaser class
var EnemyLaser = Container.expand(function (x, y) {
var self = Container.call(this);
var enemyLaserGraphics = self.attachAsset('enemylaser', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
self.x = x;
self.y = y;
self.speed = 10;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
});
// EnemyShip class
var EnemyShip = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemyship', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
self.shoot = function () {
var enemyLaser = new EnemyLaser(self.x, self.y + enemyGraphics.height / 2);
game.addChild(enemyLaser);
enemyLasers.push(enemyLaser);
};
});
// Laser class
var Laser = Container.expand(function (x, y) {
var self = Container.call(this);
var laserGraphics = self.attachAsset('laser', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = x;
self.y = y;
self.speed = -15;
self.update = function () {
self.y += self.speed;
if (self.y < 0) {
self.destroy();
}
};
});
var NewEnemy = Container.expand(function () {
var self = Container.call(this);
var newEnemyGraphics = self.attachAsset('box', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
self.shoot = function () {
var enemyLaser = new EnemyLaser(self.x, self.y + newEnemyGraphics.height / 2);
game.addChild(enemyLaser);
enemyLasers.push(enemyLaser);
};
});
var RareEnemy = Container.expand(function () {
var self = Container.call(this);
var rareEnemyGraphics = self.attachAsset('rareEnemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
self.shoot = function () {
var enemyLaser = new EnemyLaser(self.x, self.y + rareEnemyGraphics.height / 2);
game.addChild(enemyLaser);
enemyLasers.push(enemyLaser);
};
});
//<Assets used in the game will automatically appear here>
// SpaceShip class
var SpaceShip = Container.expand(function () {
var self = Container.call(this);
var shipGraphics = self.attachAsset('spaceship', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.update = function () {
self.y = 2732 - 200;
};
self.shoot = function () {
var laser = new Laser(self.x, self.y - shipGraphics.height / 2);
game.addChild(laser);
lasers.push(laser);
LK.getSound('new_laser_sound_id').play();
};
});
// Star class
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.y = -starGraphics.height;
self.x = Math.random() * 2048;
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Play background music
LK.playMusic('space');
// Removed incorrect sound play call
// Initialize arrays and variables
var spaceship;
var enemies = [];
var lasers = [];
var enemyLasers = [];
var stars = [];
var score = 0;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var boss = null;
var bossKilled = false;
// Create spaceship
spaceship = new SpaceShip();
spaceship.x = 2048 / 2;
spaceship.y = 2732 - 200;
game.addChild(spaceship);
// Create and add stars
for (var i = 0; i < 50; i++) {
var star = new Star();
star.x = Math.random() * 2048;
star.y = Math.random() * 2732;
stars.push(star);
game.addChild(star);
}
// Spawn enemies
function spawnEnemy() {
var enemy;
if (Math.random() < 0.5) {
enemy = new EnemyShip();
} else {
enemy = new NewEnemy();
}
enemy.x = Math.random() * 2048;
enemy.y = -100;
enemies.push(enemy);
game.addChild(enemy);
}
// Spawn rare enemies
function spawnRareEnemy() {
var rareEnemy = new RareEnemy();
rareEnemy.x = Math.random() * 2048;
rareEnemy.y = -100;
enemies.push(rareEnemy);
game.addChild(rareEnemy);
}
// Handle game updates
game.update = function () {
// Update spaceship
spaceship.update();
// Update stars
for (var i = stars.length - 1; i >= 0; i--) {
stars[i].update();
}
// Update lasers
for (var i = lasers.length - 1; i >= 0; i--) {
lasers[i].update();
if (lasers[i].y < 0) {
lasers[i].destroy();
lasers.splice(i, 1);
}
}
// Update enemy lasers
for (var i = enemyLasers.length - 1; i >= 0; i--) {
enemyLasers[i].update();
if (enemyLasers[i].y > 2732) {
enemyLasers[i].destroy();
enemyLasers.splice(i, 1);
}
}
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
enemies[i].update();
if (enemies[i].y > 2732) {
enemies[i].destroy();
enemies.splice(i, 1);
}
}
// Check for collisions
for (var i = lasers.length - 1; i >= 0; i--) {
for (var j = enemies.length - 1; j >= 0; j--) {
if (lasers[i].intersects(enemies[j])) {
lasers[i].destroy();
var destroyEffect = LK.getAsset('destroy', {
anchorX: 0.5,
anchorY: 0.5,
x: enemies[j].x,
y: enemies[j].y
});
game.addChild(destroyEffect);
LK.setTimeout(function () {
destroyEffect.destroy();
}, 200);
LK.getSound('explosion').play();
if (enemies[j] instanceof RareEnemy || enemies[j] instanceof NewEnemy) {
score += 10;
} else {
score++;
}
enemies[j].destroy();
lasers.splice(i, 1);
enemies.splice(j, 1);
scoreTxt.setText(score);
if (score >= 100 && !boss && !bossKilled) {
boss = new Boss();
boss.x = 2048 / 2;
boss.y = -boss.height;
game.addChild(boss);
}
break;
}
}
if (boss && boss.intersects && lasers[i] && lasers[i].intersects(boss)) {
lasers[i].destroy();
var destroyEffect = LK.getAsset('destroy', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
x: boss.x,
y: boss.y
});
game.addChild(destroyEffect);
LK.setTimeout(function () {
destroyEffect.destroy();
}, 200);
LK.getSound('explosion').play();
boss.health--;
if (boss.health <= 0) {
var kabomEffects = [];
for (var i = 0; i < 3; i++) {
var kabomEffect = LK.getAsset('kabom', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: boss.width / 400,
scaleY: boss.height / 400,
x: boss.x + (Math.random() - 0.5) * boss.width / 2,
y: boss.y + (Math.random() - 0.5) * boss.height / 2
});
game.addChild(kabomEffect);
kabomEffects.push(kabomEffect);
}
LK.setTimeout(function () {
for (var i = 0; i < kabomEffects.length; i++) {
kabomEffects[i].destroy();
}
}, 200);
LK.getSound('kabom').play();
boss.destroy();
boss = null;
bossKilled = true;
}
lasers.splice(i, 1);
score++;
scoreTxt.setText(score);
break;
}
}
for (var i = enemyLasers.length - 1; i >= 0; i--) {
if (enemyLasers[i].intersects(spaceship)) {
enemyLasers[i].destroy();
enemyLasers.splice(i, 1);
// Flash screen red for 1 second (1000ms) to show we are dead.
LK.effects.flashScreen(0xff0000, 1000);
// Show game over. The game will be automatically paused while game over is showing.
LK.showGameOver(); // Calling this will destroy the 'Game' and reset entire game state.
break;
}
}
// Spawn enemies periodically if boss is not present
if (LK.ticks % 60 == 0) {
if (Math.random() < 0.10) {
spawnRareEnemy();
} else {
spawnEnemy();
}
}
// Enemies shoot periodically if boss is not present
if (LK.ticks % 120 == 0) {
for (var i = 0; i < enemies.length; i++) {
enemies[i].shoot();
}
}
if (boss) {
boss.update();
if (boss.health > 5 && LK.ticks % 60 == 0) {
boss.shoot();
}
}
};
// Handle touch events
game.down = function (x, y, obj) {
spaceship.shoot();
};
game.move = function (x, y, obj) {
spaceship.x = x;
};
game.up = function (x, y, obj) {
// No action needed on touch up
};
// Add method to resume enemy spawning
Boss.prototype.resumeEnemySpawning = function () {
// Spawn enemies periodically
if (LK.ticks % 60 == 0 && !boss) {
spawnEnemy();
}
// Enemies shoot periodically
if (LK.ticks % 120 == 0 && !boss) {
for (var i = 0; i < enemies.length; i++) {
enemies[i].shoot();
}
}
};
star white. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
enemy space ship boss it should be big and looking from top. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
explosion. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
linear laser red horizontal. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
red pixel circle with black background and hearth on middle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
red circle with black background and bullet on middle next to x2 symbol. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.