Code edit (3 edits merged)
Please save this source code
User prompt
The traderGraphics should start at scaleX,scaleY of 0,0 and be set in the update statement to: `1 - counter / TRADER_SPAWN_TIME` after setting the position
Code edit (7 edits merged)
Please save this source code
User prompt
The traderGraphics should start at a random point within TRADER_SPAWN_RADIUS, and move towards the 0,0 position over TRADER_SPAWN_TIME
User prompt
Add 5 globals: `TRADER_SPAWN_RADIUS = 1000`, `TRADER_SPAWN_TIME = 2 * GAME_TICKS`, `TRADER_MOVE_ANCHOR = 0.25`, `TRADER_MOVE_ROTATION = 0.15` and `TRADER_MOVE_INTERVAL = 5`
User prompt
Fix Bug: 'ReferenceError: trader is not defined' in or related to this line: 'var traderGraphics = self.attachAsset('trader', {' Line Number: 1300
User prompt
Trader graphics should start off screen and move towards it's 0,0 point
Code edit (1 edits merged)
Please save this source code
Code edit (13 edits merged)
Please save this source code
User prompt
Fix Bug: 'SecurityError: Permission denied to access property "removeChild" on cross-origin object' in or related to this line: 'baseDestroy();' Line Number: 529
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: t is undefined' in or related to this line: 'symbolAsset = self.attachAsset(newSymbol, {' Line Number: 183
Code edit (2 edits merged)
Please save this source code
User prompt
in the transitionPlanets function, destroy all traders and reset the array
User prompt
in the transitionPlanets function, destroy all asteroids and reset the array
Code edit (6 edits merged)
Please save this source code
User prompt
Remove any remaining console logs
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
Add an asset with id "point" to BorderedSymbol and SymbolText
User prompt
Add an asset with id "point" to BorderedText, BorderedSymbol and SymbolText
Code edit (1 edits merged)
Please save this source code
User prompt
Created traders should be added to the foreground
User prompt
Created asteroids should be added to the midground and created traders should be added to the foreground
Code edit (9 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -627,10 +627,11 @@
if (quantity > 0) {
if (planterButton) {
planterButton.updateImage(fruitName);
} else {
- planterButton = self.addChild(new PlantButton(fruitName, function () {
+ planterButton = self.addChild(new PlanterButton(fruitName, function () {
self.tryPlantFruit(inventory.getSelection());
+ skipRetarget = true;
}, {
scale: SCALE_FRUIT_PLANTER
}));
}
@@ -1096,9 +1097,9 @@
;
buttonBackground.on('down', callback);
return self;
});
-var PlantButton = BasicButton.expand(function (plantName, callback, config) {
+var PlanterButton = BasicButton.expand(function (plantName, callback, config) {
var self = BasicButton.call(this, plantName, callback, config);
var arrow = self.attachAsset('arrow', {
y: PLANT_BUTTON_OFFSET / 2,
anchorX: 0.5,
@@ -1235,17 +1236,26 @@
var self = ConfigContainer.call(this, config);
var index = config.index;
var traderGraphics = self.attachAsset('trader', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ x: self.x < GAME_WIDTH / 2 ? -trader.width : GAME_WIDTH + trader.width
});
+ self.update = function () {
+ var targetX = self.x < GAME_WIDTH / 2 ? 0 : GAME_WIDTH;
+ self.x += self.x < GAME_WIDTH / 2 ? TRADER_SPEED : -TRADER_SPEED;
+ if (self.x < GAME_WIDTH / 2 && self.x >= targetX || self.x > GAME_WIDTH / 2 && self.x <= targetX) {
+ self.update = null; // Stop updating once the trader reaches its target
+ }
+ };
var trade = setTrade || generateTrade();
var traderDialogue = self.addChild(new TraderDialogue(handleTradeCallback, trade, {
y: -traderGraphics.height / 2 - TRADER_SHIP_SPACING,
flipX: self.x < GAME_WIDTH / 2 ? -1 : 1
}));
;
function handleTradeCallback(accepted) {
+ skipRetarget = true;
if (accepted) {
if (checkValue(trade.sellName, trade.sellAmount)) {
makeAdjustment(trade.sellName, -trade.sellAmount);
makeAdjustment(trade.buyName, trade.buyAmount);
@@ -1494,9 +1504,9 @@
var WEEDS_SPAWN_TIME = 5 * 60 * GAME_TICKS;
var WEEDS_SPAWN_VARIANCE = 2 * 60 * GAME_TICKS;
var WEEDS_SPREAD_TIME = 1 * 60 * GAME_TICKS;
var WEEDS_SPREAD_VARIANCE = 20 * GAME_TICKS;
-var GROW_WARNING_BARREN = 'Nothing grows on this planet!';
+var GROW_WARNING_BARREN = 'Nothing grows on this planet';
var GROW_WARNING_GENERAL = 'This cannot grow on this plant';
var PLANT_GROWTH_FACTOR = 0.1;
var PLANT_BUTTON_OFFSET = -220;
var PLANT_FRUIT_SCALE = 0.6;
@@ -1661,8 +1671,10 @@
buyAmount: 1,
sellName: 'fruitWeeds',
sellAmount: 5
};
+var skipRetarget = false;
+var retargetAngle;
var targetAngle = PLAYER_START_ANGLE;
var currentPlanet = NAVIGATION[0];
var destinationPlanet = NAVIGATION[0];
var background = game.addChild(new Background());
@@ -1694,8 +1706,14 @@
// Gameplay events
//==============================================================================
;
LK.on('tick', function () {
+ if (skipRetarget) {
+ skipRetarget = false;
+ } else if (retargetAngle !== undefined) {
+ targetAngle = retargetAngle;
+ }
+ retargetAngle = undefined;
if (player) {
player.update();
}
ship.update();
@@ -1716,9 +1734,9 @@
var dy = clickPosition.y - planet.y;
var sqrDistance = dx * dx + dy * dy;
var range = planet.radius + PLAYER_BUFFER_DIST;
if (sqrDistance <= range * range) {
- targetAngle = Math.atan2(dy, dx) - planet.rotation;
+ retargetAngle = Math.atan2(dy, dx) - planet.rotation;
}
}
});
;
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.