User prompt
Implement a method within the Player class that allows shooting lasers.
User prompt
Create a Laser Class
User prompt
Implement a method within the Player class that allows shooting lasers.
User prompt
Create a Laser Class
User prompt
Make the laser go up.
User prompt
Add laser asset that shoots the rocks from the player asset.
User prompt
Make the obstacles a bit smaller and make the player bigger.
Remix started
Copy Quintillion Quadrilaterals
===================================================================
--- original.js
+++ change.js
@@ -64,9 +64,10 @@
var laserGraphics = self.attachAsset('laser', {
anchorX: 0.5,
anchorY: 1
});
- self.speed = -10;
+ laserGraphics.scale.set(0.8); // Scale down the laser
+ self.speed = 10; // Set speed
self.move = function () {
self.y -= self.speed;
};
});
@@ -84,14 +85,8 @@
};
self.moveRight = function () {
self.x = Math.min(2048 - self.width / 2, self.x + self.speed);
};
- self.shoot = function () {
- var laser = new Laser();
- laser.x = self.x;
- laser.y = self.y;
- return laser;
- };
self.update = function () {
// Player update logic
};
});
@@ -162,13 +157,8 @@
newObstacle.y = -newObstacle.height;
obstacles.push(newObstacle);
game.addChild(newObstacle);
}
- if (LK.ticks % 30 == 0) {
- // Every 0.5 second
- var laser = player.shoot();
- game.addChild(laser);
- }
// Move obstacles and check for collisions
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].move();
obstacles[i].increaseSpeed();
@@ -177,12 +167,7 @@
obstacles.splice(i, 1);
} else if (player.intersects(obstacles[i])) {
isGameOver = true;
gameStats.incrementGamesPlayed();
- } else if (laser && laser.intersects(obstacles[i])) {
- obstacles[i].destroy();
- obstacles.splice(i, 1);
- laser.destroy();
- laser = null;
}
}
});
\ No newline at end of file
Spaceship 2D Pixel.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Asteroid 2D Pixel.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Galaxy Background 2D Pixel.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.