User prompt
create asteroids which are spawn randomly on the game
User prompt
move the player only when mouse input is detected
User prompt
remove enemy class and its code
User prompt
restrict the enemy movement only on x axis and forward
User prompt
add enemy which spawns and move towards the player
User prompt
when i click the left mouse button the player character shoots a bullet
User prompt
spawn the player little above on the scree
User prompt
spawn the player on the bottom part of the screen
User prompt
restrict the mouse input only to x axis
User prompt
use mouse as a input
User prompt
create a player class
User prompt
remove everything
User prompt
change this game into space fighter
User prompt
make enemy class to move towards the player
User prompt
make the enemy to move towards player
User prompt
generate game like 1941: Counter Attack
User prompt
remove everything
User prompt
remove space fighter
User prompt
create a space fighter game
User prompt
add a xwing
User prompt
create a asset and replace that asset with the default backgroundColor
User prompt
delete space fighter
User prompt
var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); replace the background color with asset and make this asset into lively background
User prompt
remove enemy laser and its code
User prompt
fit the game background with screen size
/**** * Classes ****/ var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -3; self.update = function () { self.y += self.speed; if (self.y < -50) { self.destroy(); } }; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { if (self.x < 0) { self.x = 0; } if (self.x > 2048) { self.x = 2048; } if (self.y < 0) { self.y = 0; } if (self.y > 2732) { self.y = 2732; } }; }); var Spaceship = Container.expand(function () { var self = Container.call(this); var spaceshipGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y -= self.speed; if (self.y < -50) { self.destroy(); } }; }); /**** * Initialize Game ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var player = game.addChild(new Player()); player.x = 1024; player.y = 2400; var enemies = []; var bullets = []; game.update = function () { if (LK.ticks % 60 == 0) { var enemy = game.addChild(new Enemy()); enemy.x = Math.random() * 2048; enemy.y = 0; enemies.push(enemy); } for (var i = bullets.length - 1; i >= 0; i--) { var bullet = bullets[i]; for (var j = enemies.length - 1; j >= 0; j--) { var enemy = enemies[j]; if (bullet.intersects(enemy)) { bullet.destroy(); bullets.splice(i, 1); enemy.destroy(); enemies.splice(j, 1); break; } } } }; game.down = function (x, y, obj) { var spaceship = game.addChild(new Spaceship()); spaceship.x = player.x; spaceship.y = player.y; bullets.push(spaceship); }; game.move = function (x, y, obj) { player.x = x; player.y = y; };
===================================================================
--- original.js
+++ change.js
@@ -1,41 +1,17 @@
/****
* Classes
****/
-var Bullet = Container.expand(function () {
- var self = Container.call(this);
- var bulletGraphics = self.attachAsset('bullet', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 5;
- self.update = function () {
- self.y -= self.speed;
- if (self.y < -50) {
- self.destroy();
- }
- };
-});
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -3;
self.update = function () {
- // Calculate the direction vector from enemy to player
- var dx = player.x - self.x;
- var dy = player.y - self.y;
- var mag = Math.sqrt(dx * dx + dy * dy);
- // Normalize the direction vector
- dx /= mag;
- dy /= mag;
- // Move the enemy towards the player
- self.x += dx * self.speed;
- self.y += dy * self.speed;
- // Destroy the enemy if it goes off screen
- if (self.y < -50 || self.y > 2782 || self.x < -50 || self.x > 2098) {
+ self.y += self.speed;
+ if (self.y < -50) {
self.destroy();
}
};
});
@@ -60,8 +36,22 @@
self.y = 2732;
}
};
});
+var Spaceship = Container.expand(function () {
+ var self = Container.call(this);
+ var spaceshipGraphics = self.attachAsset('bullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 5;
+ self.update = function () {
+ self.y -= self.speed;
+ if (self.y < -50) {
+ self.destroy();
+ }
+ };
+});
/****
* Initialize Game
****/
@@ -100,12 +90,12 @@
}
}
};
game.down = function (x, y, obj) {
- var bullet = game.addChild(new Bullet());
- bullet.x = player.x;
- bullet.y = player.y;
- bullets.push(bullet);
+ var spaceship = game.addChild(new Spaceship());
+ spaceship.x = player.x;
+ spaceship.y = player.y;
+ bullets.push(spaceship);
};
game.move = function (x, y, obj) {
player.x = x;
player.y = y;
Space craft in facing forward. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
spacecraft in 4k
fire blast. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
asteroid. Single Game Texture. In-Game asset. 2d. No shadows
dark nebula galaxy 4k. Single Game Texture. In-Game asset. 2d. Blank background. No shadows