User prompt
in the asteroids constructor, calculate the velocityX and velocityY based on current position and the targetX and targetY
User prompt
if an asteroid's update statement returns true, remove from the array list and destroy the asteroid
Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: asteroidInstance is undefined' in or related to this line: 'var asteroidInstance = new Asteroid({' Line Number: 635
Code edit (1 edits merged)
Please save this source code
User prompt
update all asteroids in the on tick callbacl
User prompt
asteroids should travel to the other side of the screen before being destroyed
User prompt
add an asteroidList array and add any created asteroids to the list
Code edit (6 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: this.scale is undefined' in or related to this line: 'var side = Math.random() < 0.5 ? -Asteroid.prototype.width : GAME_WIDTH;' Line Number: 622
User prompt
Every tick there is a 1% chance to spawn an Asteroid on either the left or right of the screen (full screen height, spawns slightly off-screen)
User prompt
Create an Asteroid class that extends the ConfigContainer class, and has a slow random rotation.
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
tint the inventory's selector red
Code edit (5 edits merged)
Please save this source code
User prompt
Create an inventorySelector asset and a selectSlot function (that takes in an index) in the Inventory class. When clicking on a InventorySlot, it should call the parent (Inventory) selectSlot function and the Inventory should attach the inventorySelector asset to that InventorySlot instance.
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: self.anchor is undefined' in or related to this line: 'self.anchor.set(config.anchorX || 0, config.anchorY || 0);' Line Number: 459
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: config is undefined' in or related to this line: 'self.x = config.x || 0;' Line Number: 456
User prompt
Fix Bug: 'TypeError: LK.attachAsset is not a function' in or related to this line: 'var frameAsset = LK.attachAsset('inventoryFrame', {});' Line Number: 447
Code edit (5 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: LK.attachAsset is not a function' in or related to this line: 'var frameAsset = LK.attachAsset('inventoryFrame', {' Line Number: 455
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -494,18 +494,19 @@
var asteroidGraphics = self.attachAsset('asteroid', {
anchorX: 0.5,
anchorY: 0.5
});
+ var side = self.x < 0;
+ var targetY = ASTEROID_TARGET_OFFSET + Math.random() * (GAME_HEIGHT - 2 * ASTEROID_TARGET_OFFSET);
+ var targetX = side ? GAME_WIDTH + ASTEROID_SIZE : -ASTEROID_SIZE;
var rotationSpeed = (Math.random() - 0.5) * 0.01;
- self.update = function () {
+ ;
+ self.update = update;
+ ;
+ function update() {
self.rotation += rotationSpeed;
- // Move the asteroid horizontally across the screen
- self.x += self.vx;
- // Check if the asteroid has reached the opposite side of the screen
- if (self.vx < 0 && self.x < -self.width || self.vx > 0 && self.x > GAME_WIDTH + self.width) {
- self.destroy(); // Destroy the asteroid when it's off-screen
- }
- };
+ return side ? self.x > targetX : self.x < targetX;
+ }
});
/****
* Initialize Game
@@ -554,11 +555,13 @@
var CROSSHAIR_DIST = 40;
var CROSSHAIR_VARIANCE = 10;
var CROSSHAIR_PERIOD = 1.25 * GAME_TICKS / MATH_2_PI;
var INVENTORY_ROWS = 1;
-var ASTEROID_SPEED = 5; // Speed at which asteroids move across the screen
var INVENTORY_COLS = 8;
var INVENTORY_SLOT_SIZE = 100;
+var ASTEROID_SPEED = 5;
+var ASTEROID_SIZE = 100;
+var ASTEROID_TARGET_OFFSET = 500;
var NAVIGATION = [{
cost: 0,
"class": PlanetGrey,
planet: 'planetGrey',
@@ -623,24 +626,26 @@
ship.update();
planet.update();
crosshair.update();
for (var i = asteroidList.length - 1; i >= 0; i--) {
- asteroidList[i].update();
+ if (asteroidList[i].update()) {
+ asteroidList[i].destroy();
+ asteroidList.splice(i, 1);
+ }
}
spawnAsteroidWithChance();
});
;
function spawnAsteroidWithChance() {
if (Math.random() < 0.01) {
var side = Math.random() < 0.5;
asteroidList.push(game.addChild(new Asteroid({
- x: side ? -asteroidInstance.width : GAME_WIDTH + asteroidInstance.width,
+ x: side ? -ASTEROID_SIZE : GAME_WIDTH + ASTEROID_SIZE,
y: Math.random() * GAME_HEIGHT,
vx: side ? ASTEROID_SPEED : -ASTEROID_SPEED
})));
}
}
-;
function transitionPlanets() {
LK.effects.flashScreen(0x000000, 500);
currentPlanet = destinationPlanet;
planet.parent.removeChild(planet);
pixel art of a tiny planet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a planet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of an alien currency symbol. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a planet made of gold ore. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
plain black background with stars. 2d repeating Texture.
pixel art of a asteroid. Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a cute alien farmer, side view. Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a rocky explosion.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art flame particle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a large white, empty, rectangular, speech bubble. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a red chevron. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art of yellow grapes. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.