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
@@ -32,25 +32,10 @@
var size = config.size !== undefined ? config.size : TEXT_DEFAULT_SIZE;
var font = config.font !== undefined ? config.font : TEXT_DEFAULT_FONT;
var textFill = config.fill !== undefined ? config.fill : TEXT_DEFAULT_FILL;
var borderFill = config.border !== undefined ? config.border : TEXT_DEFAULT_BORDER;
- var textConfig = {
- fill: textFill,
- font: font,
- size: size,
- anchorX: anchorX,
- anchorY: anchorY
- };
- var borderConfig = {
- fill: borderFill,
- font: font,
- size: size,
- anchorX: anchorX,
- anchorY: anchorY
- };
var mainAsset;
var textAssets = [];
- console.log(text, anchorX, anchorY);
;
self.setText = setText;
self.setFill = setFill;
;
@@ -59,29 +44,31 @@
textAssets[i].setText(newText);
}
}
function setFill(newFill) {
- mainAsset.fill = newFill;
+ mainAsset.fill = textFill = newFill;
}
function buildTextAssets(newText) {
for (var i = 0; i < TEXT_OFFSETS.length; i++) {
+ var main = i === TEXT_OFFSETS.length - 1;
var textAsset = textAssets[i];
if (textAsset) {
textAsset.destroy();
}
- textAsset = self.addChild(new Text2(newText, i === TEXT_OFFSETS.length - 1 ? textConfig : borderConfig));
- textAsset.anchorX = anchorX;
- textAsset.anchorY = anchorY;
- textAsset.x = TEXT_OFFSETS[i][0] * TEXT_BORDER_WEIGHT;
- textAsset.y = TEXT_OFFSETS[i][1] * TEXT_BORDER_WEIGHT;
+ textAsset = self.addChild(new Text2(newText, {
+ fill: main ? textFill : borderFill,
+ font: font,
+ size: size
+ }));
+ textAsset.anchor = {
+ x: anchorX,
+ y: anchorY
+ }; // NOTE: Cannot be set in config
+ textAsset.x = TEXT_OFFSETS[i][0] * TEXT_BORDER_WEIGHT; // NOTE: Cannot be set in config
+ textAsset.y = TEXT_OFFSETS[i][1] * TEXT_BORDER_WEIGHT; // NOTE: Cannot be set in config
textAssets[i] = textAsset;
}
mainAsset = textAssets[TEXT_OFFSETS.length - 1];
- self.attachAsset('point', {
- anchorX: 0.5,
- anchorY: 0.5,
- tint: 0xFF0000
- }); // TEMP
}
;
buildTextAssets(text);
return self;
@@ -113,39 +100,35 @@
var anchorX = config.anchorX !== undefined ? config.anchorX : .5;
var anchorY = config.anchorY !== undefined ? config.anchorY : .5;
var symbolTint = config.tint !== undefined ? config.tint : 0xFFFFFF;
var borderTint = config.border !== undefined ? config.border : TEXT_DEFAULT_BORDER;
- var symbolConfig = {
- // tint: symbolTint,
- tint: 0xFFFFFF,
- anchorX: anchorX,
- anchorY: anchorY
- };
- var borderConfig = {
- // tint: borderTint,
- tint: 0x000000,
- anchorX: anchorX,
- anchorY: anchorY
- };
var mainSymbol;
var symbolAssets = [];
;
self.setSymbol = buildSymbolAssets;
self.setTint = setTint;
;
function setTint(newTint) {
+ // NOTE: Tinting is currently broken (cannot use string)
// mainSymbol.tint = newTint;
// symbolConfig.tint = newTint;
}
function buildSymbolAssets(newSymbol) {
for (var i = 0; i < TEXT_OFFSETS.length; i++) {
+ var main = i === TEXT_OFFSETS.length - 1;
var symbolAsset = symbolAssets[i];
if (symbolAsset) {
symbolAsset.destroy();
}
- symbolAsset = self.attachAsset(newSymbol, {});
- symbolAsset.x = TEXT_OFFSETS[i][0] * TEXT_BORDER_WEIGHT;
- symbolAsset.y = TEXT_OFFSETS[i][1] * TEXT_BORDER_WEIGHT;
+ symbolAsset = self.attachAsset(newSymbol, {
+ // tint: main ? symbolTint : borderTint,
+ tint: main ? 0xFFFFFF : 0x000000,
+ // NOTE: Tinting is currently broken (cannot use string)
+ x: TEXT_OFFSETS[i][0] * TEXT_BORDER_WEIGHT,
+ y: TEXT_OFFSETS[i][1] * TEXT_BORDER_WEIGHT,
+ anchorX: anchorX,
+ anchorY: anchorY
+ });
if (width !== undefined && height === undefined) {
height = symbolAsset.height * (width / symbolAsset.width);
} else if (height !== undefined && width === undefined) {
width = symbolAsset.width * (height / symbolAsset.height);
@@ -157,13 +140,8 @@
}
symbolAssets[i] = symbolAsset;
}
mainSymbol = symbolAssets[TEXT_OFFSETS.length - 1];
- self.attachAsset('point', {
- anchorX: 0.5,
- anchorY: 0.5,
- tint: '#FF0000'
- }); // TEMP
}
;
buildSymbolAssets(symbol);
return self;
@@ -210,13 +188,8 @@
height: size,
tint: tint ? config.fill : undefined,
border: config.border // Passthrough
}));
- self.attachAsset('point', {
- anchorX: 0.5,
- anchorY: 0.5,
- tint: '#0000FF'
- }); // TEMP
;
self.setText = setText;
self.setFill = setFill;
self.setSymbol = setSymbol;
@@ -224,9 +197,9 @@
function alignAssets() {
var first = prefix ? symbolAsset : textAsset;
var second = prefix ? textAsset : symbolAsset;
var totalWidth = symbolAsset.width + margin + textAsset.width;
- var heightOffset = 0; // Math.max(first.height, second.height) * (anchorY - 0.5);
+ var heightOffset = Math.max(first.height, second.height) * (0.5 - anchorY);
first.x = -totalWidth * anchorX;
first.y = heightOffset;
second.x = first.x + first.width + margin;
second.y = heightOffset;
@@ -861,9 +834,9 @@
var button = buttons[planet];
if (button.unlocked) {
setDestination(planet);
} else if (money >= button.cost) {
- moneyDisplay.setAmount(money -= button.cost);
+ moneyDisplay.setText(money -= button.cost);
button.unlock();
}
}
self.setDestination = setDestination;
@@ -1311,9 +1284,9 @@
suffix: true,
tint: true
}));
} else {
- return tradeSymbols.addChild(new SymbolText(amount + 'x', name, {
+ return tradeSymbols.addChild(new SymbolText(amount + '×', name, {
x: config.x,
anchorX: config.anchorX,
anchorY: 0.5,
suffix: true
@@ -1365,9 +1338,9 @@
var TEXT_DEFAULT_BORDER = '#000000'; // Required by: BorderedText, BorderedSymbol, SymbolText
var TEXT_DEFAULT_FILL = '#FFFFFF'; // Required by: BorderedText, SymbolText
var TEXT_DEFAULT_FONT = 'Arial'; // Required by: BorderedText, SymbolText
var TEXT_DEFAULT_SIZE = 50; // Required by: BorderedText, SymbolText
-var TEXT_DEFAULT_MARGIN = 10; // Required by: SymbolText
+var TEXT_DEFAULT_MARGIN = 0; // Required by: SymbolText
;
// Game constants
var GAME_TICKS = 60;
var GAME_WIDTH = 2048;
@@ -1428,9 +1401,9 @@
var TRADER_TIME_VARIANCE = 2 * 60 * GAME_TICKS;
var TRADER_COST_VARIANCE = 0.1;
var TRADER_ASK_MIN = 5; // Minimum quantity of items to buy
var TRADER_ASK_MAX = 1.2; // Maximum of current stock to buy
-var TRADER_FRAME_OFFSET_X = 0.13;
+var TRADER_FRAME_OFFSET_X = 0.1;
var TRADER_FRAME_OFFSET_Y = -0.56;
var TRADER_DETAIL_MARGIN = 20;
var TRADER_SHIP_SPACING = 50;
;
@@ -1652,9 +1625,8 @@
trySpawnTrader();
});
;
game.on('down', function (obj) {
- console.log(obj);
if (player) {
var clickPosition = obj.event.getLocalPosition(game);
var dx = clickPosition.x - planet.x;
var dy = clickPosition.y - planet.y;
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.