User prompt
When updating score textg also call LK.setScore
User prompt
Make ship shoot twice as fast
Code edit (1 edits merged)
Please save this source code
User prompt
Make ship shoot twice as fast
User prompt
Add powerups to the game that makes the ship shoot two bullets side by side for 5 seconds.
User prompt
Make ship shoot twice as fast
User prompt
Make ship shoot twice as fast
User prompt
Fix Bug: 'ReferenceError: Can't find variable: HeroBullet' in this line: 'var bullet = new HeroBullet();' Line Number: 84
===================================================================
--- original.js
+++ change.js
@@ -2,18 +2,24 @@
* Classes
****/
var HeroBullet = Container.expand(function () {
var self = Container.call(this);
- var bulletGraphics = LK.getAsset('heroBullet', 'Hero Bullet Graphics', 0.5, 0.5);
+ var bulletGraphics = LK.getAsset('heroBullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
self.addChild(bulletGraphics);
self.speed = 10;
self.move = function () {
self.y -= self.speed;
};
});
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
- var bulletGraphics = LK.getAsset('enemyBullet', 'Enemy Bullet Graphics', 0.5, 0.5);
+ var bulletGraphics = LK.getAsset('enemyBullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
self.addChild(bulletGraphics);
self.speed = 5;
self.move = function () {
self.x += self.speedX;
@@ -21,14 +27,20 @@
};
});
var Hero = Container.expand(function () {
var self = Container.call(this);
- var heroGraphics = LK.getAsset('hero', 'Hero Spaceship', 0.5, 0.5);
+ var heroGraphics = LK.getAsset('hero', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
self.addChild(heroGraphics);
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
- var enemyGraphics = LK.getAsset('enemy', 'Enemy Spaceship', 0.5, 0.5);
+ var enemyGraphics = LK.getAsset('enemy', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
self.addChild(enemyGraphics);
self.speed = 6;
self.targetY = Math.random() * (2732 / 3);
self.move = function () {
@@ -45,9 +57,12 @@
};
});
var StarField = Container.expand(function () {
var self = Container.call(this);
- var starGraphics = LK.getAsset('star', 'Star Graphics', 0.5, 0.5);
+ var starGraphics = LK.getAsset('star', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
self.addChild(starGraphics);
self.speed = Math.random() * 2 + 1;
self.alpha = self.speed / 3;
self.move = function () {
@@ -161,9 +176,8 @@
}
}
});
});
-
// Check collisions between enemy bullets and hero
enemyBullets.forEach(function (enemyBullet, index) {
if (enemyBullet.intersects(hero)) {
enemyBullet.destroy();
@@ -207,9 +221,9 @@
if (allEnemiesKilled) {
currentWave++;
spawnWave();
}
- if (LK.ticks % 5 === 0) {
+ if (LK.ticks % 15 === 0) {
fireHeroBullet();
}
enemies.forEach(function (enemy, index) {
if (LK.ticks % 90 === 0) {
Single space torpedo flying upwards Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
Single enemy slime bullet flying downwards. Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
single alien enemy spaceship facing down, looking like space alien adopted to living in space. Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
Hero spaceship facing upwards, with a single cannon in the center. Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.