User prompt
Add a lot of enemies
User prompt
Make enemy movement faster and faster after score of 100
User prompt
Movement can be zigzag and others too
User prompt
Enemy movement random on whole screen
User prompt
Power ups and rubbish can't overlap
User prompt
Movement of enemy must be UpTo lower screen
User prompt
Move hearts a little right
User prompt
Delete star asset
User prompt
Delete Background asset
User prompt
Remove the bugs which are causing the game to crash
User prompt
Replace dark background with given Background asset
User prompt
More left
User prompt
Display score a little left
User prompt
Enemy can collide with player too
User prompt
Enemy should move in all directions as like player
User prompt
Enemy should move in all directions
User prompt
Display score board on right side and a little bigger
User prompt
Make 5 hearts instead of writing lives:3
User prompt
Bullets go continuesly
User prompt
Upon getting power ups bullets increases and scatter in all directions
User prompt
Aliens throws some rubbish too upon which by colliding 1 life will be over and make a 5 lives system. After 5 lives are over, game will be over
User prompt
Aliens throw some power ups too and move towards players slowly first and then with speed, Making it difficult to keep stance at a point. Make the player to move on whole screen
User prompt
Make bullets size smaller and others assets bigger
User prompt
Bigger size of characters
User prompt
Add something more to make it more playable like background animations of space and scores and lives and more things
/**** * Classes ****/ // Bullet class var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.75, scaleY: 0.75 }); self.speed = -10; self.speedX = 0; self.speedY = self.speed; self.update = function () { self.x += self.speedX; self.y += self.speedY; }; }); // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.0, scaleY: 2.0 }); self.speed = 2; self.update = function () { // Mimic player movement logic for enemy self.x += Math.sin(self.y / 50) * self.speed * 2; // Zigzag horizontal movement self.y += self.speed; // Continue downward movement }; }); // The assets will be automatically created and loaded by the LK engine // Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.0, scaleY: 2.0 }); self.speed = 5; self.update = function () { // Player movement logic goes here }; }); // PowerUp class var PowerUp = Container.expand(function () { var self = Container.call(this); var powerUpGraphics = self.attachAsset('powerUp', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); self.speed = 3; self.update = function () { self.y += self.speed; }; }); // Rubbish class var Rubbish = Container.expand(function () { var self = Container.call(this); var rubbishGraphics = self.attachAsset('rubbish', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); self.speed = 3; self.update = function () { self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize player, bullets and enemies var player = game.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 - 100; var bullets = []; var enemies = []; var score = 0; var lives = 5; var scoreText = new Text2('Score: 0', { size: 100, fill: "#ffffff" }); scoreText.x = 2048 - 500; // Move score display further to the left scoreText.y = 50; // Slightly lower from the top game.addChild(scoreText); var hearts = []; for (var i = 0; i < lives; i++) { var heart = LK.getAsset('heart', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, scaleY: 0.5, x: 40 + i * 60, y: 80 }); hearts.push(heart); game.addChild(heart); } // Game update function game.update = function () { // Player movement logic game.move = function (x, y, obj) { player.x = x; player.y = y; }; // Shooting logic if (LK.ticks % 10 == 0) { // Fire a bullet every 10 ticks var bullet = new Bullet(); bullet.x = player.x; bullet.y = player.y; bullets.push(bullet); game.addChild(bullet); } // Enemy, power-up, and rubbish spawning logic if (LK.ticks % Math.max(60, 120 - Math.floor(score / 10)) == 0) { for (var i = 0; i < Math.min(5, 1 + Math.floor(score / 50)); i++) { var enemy = new Enemy(); enemy.x = Math.random() * 2048; enemy.y = 0; enemies.push(enemy); game.addChild(enemy); } // Randomly throw power-ups if (Math.random() < 0.3) { // 30% chance to throw a power-up var powerUp = new PowerUp(); powerUp.x = enemy.x; powerUp.y = enemy.y; // Ensure power-up does not overlap with rubbish var overlap = false; for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof Rubbish && powerUp.intersects(game.children[i])) { overlap = true; break; } } if (!overlap) { game.addChild(powerUp); } } // Randomly throw rubbish if (Math.random() < 0.5) { // 50% chance to throw rubbish var rubbish = new Rubbish(); rubbish.x = enemy.x; rubbish.y = enemy.y; // Ensure rubbish does not overlap with power-ups var overlap = false; for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof PowerUp && rubbish.intersects(game.children[i])) { overlap = true; break; } } if (!overlap) { game.addChild(rubbish); } } } // Bullet and enemy update logic for (var i = bullets.length - 1; i >= 0; i--) { if (bullets[i].y < 0) { bullets[i].destroy(); bullets.splice(i, 1); } } for (var i = enemies.length - 1; i >= 0; i--) { if (enemies[i].y > 2732) { enemies[i].destroy(); enemies.splice(i, 1); } } // Collision detection for (var i = bullets.length - 1; i >= 0; i--) { for (var j = enemies.length - 1; j >= 0; j--) { if (bullets[i].intersects(enemies[j])) { bullets[i].destroy(); bullets.splice(i, 1); enemies[j].destroy(); enemies.splice(j, 1); score += 10; scoreText.setText('Score: ' + score); break; } } } // Check for collision between player and enemies for (var j = enemies.length - 1; j >= 0; j--) { if (player.intersects(enemies[j])) { enemies[j].destroy(); enemies.splice(j, 1); lives -= 1; if (hearts.length > lives) { var heartToRemove = hearts.pop(); heartToRemove.destroy(); } if (lives <= 0) { // Show game over LK.showGameOver(); } } } // Power-up collection and rubbish collision for (var i = 0; i < game.children.length; i++) { var child = game.children[i]; if (child instanceof PowerUp && player.intersects(child)) { child.destroy(); // Implement power-up effect: scatter bullets for (var angle = 0; angle < 360; angle += 45) { var scatterBullet = new Bullet(); scatterBullet.x = player.x; scatterBullet.y = player.y; scatterBullet.speedX = Math.cos(angle * Math.PI / 180) * 10; scatterBullet.speedY = Math.sin(angle * Math.PI / 180) * 10; scatterBullet.update = function () { this.x += this.speedX; this.y += this.speedY; }; bullets.push(scatterBullet); game.addChild(scatterBullet); } } else if (child instanceof Rubbish && player.intersects(child)) { child.destroy(); // Decrease life by 1 lives -= 1; if (hearts.length > lives) { var heartToRemove = hearts.pop(); heartToRemove.destroy(); } if (lives <= 0) { // Show game over LK.showGameOver(); } } } // Increase enemy speed after score reaches 100 if (score >= 100) { for (var i = 0; i < enemies.length; i++) { enemies[i].speed += 0.01; // Gradually increase speed } } };
===================================================================
--- original.js
+++ change.js
@@ -132,14 +132,16 @@
bullets.push(bullet);
game.addChild(bullet);
}
// Enemy, power-up, and rubbish spawning logic
- if (LK.ticks % 120 == 0) {
- var enemy = new Enemy();
- enemy.x = Math.random() * 2048;
- enemy.y = 0;
- enemies.push(enemy);
- game.addChild(enemy);
+ if (LK.ticks % Math.max(60, 120 - Math.floor(score / 10)) == 0) {
+ for (var i = 0; i < Math.min(5, 1 + Math.floor(score / 50)); i++) {
+ var enemy = new Enemy();
+ enemy.x = Math.random() * 2048;
+ enemy.y = 0;
+ enemies.push(enemy);
+ game.addChild(enemy);
+ }
// Randomly throw power-ups
if (Math.random() < 0.3) {
// 30% chance to throw a power-up
var powerUp = new PowerUp();
Aliens. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Space craft facing upwards. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Power ups. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Rocks. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Bullet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Red ♥️. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.