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,12 +494,15 @@
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 targetX = self.x < GAME_WIDTH / 2 ? GAME_WIDTH + ASTEROID_SIZE : -ASTEROID_SIZE;
var rotationSpeed = (Math.random() - 0.5) * 0.01;
+ // Calculate the velocities
+ var angle = Math.atan2(targetY - self.y, targetX - self.x);
+ var velocityX = ASTEROID_SPEED * Math.cos(angle);
+ var velocityY = ASTEROID_SPEED * Math.sin(angle);
;
self.update = update;
;
function update() {
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.