User prompt
update score in 100 points when enemy dies
User prompt
create a scoreboard and increase score when enemy dies
Code edit (1 edits merged)
Please save this source code
User prompt
new bullet class does not affect the enemy
User prompt
make the enemy shoot new bullet class towards the player when appearing on the screen
User prompt
make the enemy shoot new bullet class towards the player
User prompt
make the enemy shoot new bullet class
User prompt
create a new bullet class and assign it to enemy
User prompt
make enemy class shoot bullets
User prompt
create another asset same as enemy class
User prompt
create another type of same enemy class
User prompt
destroy the blast effect after hitting the enemy
User prompt
change the blasting effect as a asset
User prompt
add a blasting effect when the enemy destroys
User prompt
Please fix the bug: 'TypeError: game.getChildrenByType is not a function' in or related to this line: 'var enemies = game.getChildrenByType(Enemy);' Line Number: 25
User prompt
Please fix the bug: 'TypeError: game.getChildrenByClass is not a function' in or related to this line: 'var enemies = game.getChildrenByClass(Enemy);' Line Number: 25
User prompt
when the bullet hits the enemy class the enemy should destroy
User prompt
add damage to bullet
User prompt
remove the player movement only on x axis
User prompt
create enemies like in space fighter game
User prompt
remove asteroids and its class
User prompt
spawn asteroids infront of the player
User prompt
move player only on x axis
User prompt
when i click the left mouse button the player character shoots a bullet
User prompt
create asteroids which are spawn randomly on the game
/****
* Classes
****/
// Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
// Attach bullet asset
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
// Set bullet speed
self.speed = -5;
// Update function called every game tick
self.update = function () {
self.y += self.speed;
// Check for collision with enemy
var enemies = game.children.filter(function (child) {
return child instanceof Enemy;
});
for (var i = 0; i < enemies.length; i++) {
var enemy = enemies[i];
if (self.intersects(enemy)) {
// Destroy enemy and bullet on collision
enemy.destroy();
self.destroy();
// Add a blasting effect
var blast = self.attachAsset('blast', {
anchorX: 0.5,
anchorY: 0.5
});
blast.x = self.x;
blast.y = self.y;
game.addChild(blast);
break;
}
}
};
});
// Enemy class
var Enemy = Container.expand(function () {
var self = Container.call(this);
// Attach enemy asset
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
// Set enemy speed
self.speed = 5;
// Update function called every game tick
self.update = function () {
// Move enemy based on speed
self.y += self.speed;
};
});
// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
// Attach player asset
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
// Set player speed
self.speed = 5;
// Update function called every game tick
self.update = function () {
// Player movement is handled in game.move event
};
});
/****
* 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
****/
game.update = function () {
// Spawn an enemy every 60 ticks
if (LK.ticks % 60 == 0) {
var enemy = game.addChild(new Enemy());
// Set enemy initial position
enemy.x = Math.random() * 2048;
enemy.y = 0;
}
};
var player = game.addChild(new Player());
// Set player initial position
player.x = 1024;
player.y = 2732 - player.height / 2 - 100;
// Add mouse move event to the game
game.move = function (x, y, obj) {
// Move player only on x axis
player.x = x;
};
game.down = function (x, y, obj) {
// Create a bullet instance
var bullet = game.addChild(new Bullet());
// Set bullet initial position to player's position
bullet.x = player.x;
bullet.y = player.y;
}; ===================================================================
--- original.js
+++ change.js
@@ -24,9 +24,15 @@
// Destroy enemy and bullet on collision
enemy.destroy();
self.destroy();
// Add a blasting effect
- LK.effects.flashScreen(0xff0000, 1000);
+ var blast = self.attachAsset('blast', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ blast.x = self.x;
+ blast.y = self.y;
+ game.addChild(blast);
break;
}
}
};
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