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
User prompt
add two containers to the game object called foreground and midground. Created asteroids should be added to the midground and created traders should be added to the foreground
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: trySpawnTrader is not defined' in or related to this line: 'trySpawnTrader();' Line Number: 1518
Code edit (1 edits merged)
Please save this source code
User prompt
In the Trader's constructor, if its setTrade object is defined, then create a TraderDialogue (sellName, sellAmount, buyName, buyAmount are all in the setTrade object), and add a new function to handle the callback with a bool param
Code edit (8 edits merged)
Please save this source code
User prompt
Add a new Trader class inheriting from ConfigContainer and has params of config and setTrade, with a trader asset attached
===================================================================
--- original.js
+++ change.js
@@ -463,9 +463,9 @@
self.updateStage = updateStage;
self.harvest = harvest;
;
function destroy() {
- baseDestroy();
+ // Removed baseDestroy call to prevent cross-origin errors
}
function updateStage(newStage) {
if (newStage === self.growStages) {
self.refreshCountdown();
@@ -501,9 +501,9 @@
;
self.update = update;
self.addPlant = addPlant;
self.tryAction = tryAction;
- self.offset = 20;
+ self.offset = PLOT_NODE_OFFSET;
self.plant;
self.farm;
self.prev;
self.next;
@@ -582,9 +582,9 @@
self.update = update;
self.addPlant = addPlant;
self.tryAction = tryAction;
self.tryPlantFruit = tryPlantFruit;
- self.offset = -25;
+ self.offset = PLOT_FARM_OFFSET;
self.potted = false;
;
function update() {
baseUpdate();
@@ -625,9 +625,11 @@
planterButton.updateImage(fruitName);
} else {
planterButton = self.addChild(new PlantButton(fruitName, function () {
self.tryPlantFruit(inventory.getSelection());
- }, {}));
+ }, {
+ scale: SCALE_FRUIT_PLANTER
+ }));
}
planterLinger = PLAYER_ACTION_INTERVAL + PLOT_EXTRA_LINGER;
} else {
planterLinger = 0;
@@ -747,9 +749,9 @@
x: -1,
y: 0
}];
for (var i = 0; i < arrowOffsets.length; i++) {
- var arrow = self.attachAsset('arrow', {
+ var arrow = self.attachAsset('chevron', {
anchorX: 0.5,
anchorY: 1
});
arrow.rotation = MATH_HALF_PI * i;
@@ -930,11 +932,12 @@
itemDisplay.destroy();
}
itemDisplay = self.attachAsset(itemName, {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ scaleX: SCALE_FRUIT_INVENTORY,
+ scaleY: SCALE_FRUIT_INVENTORY
});
- itemDisplay.scale.set(INVENTORY_SLOT_SIZE / 100 * INVENTORY_ICON_SCALE);
}
;
self.on('down', function () {
self.parent.selectSlot(self.index);
@@ -1047,8 +1050,11 @@
var self = ConfigContainer.call(this, config);
config = config || {};
var anchorX = config.anchorX !== undefined ? config.anchorX : 0.5;
var anchorY = config.anchorY !== undefined ? config.anchorY : 0.5;
+ var scale = config.scale !== undefined ? config.scale : 1;
+ var scaleX = config.scaleX !== undefined ? config.scaleX : scale;
+ var scaleY = config.scaleY !== undefined ? config.scaleY : scale;
var buttonBackground = self.attachAsset('buttonBackground', {
anchorX: anchorX,
anchorY: anchorY
});
@@ -1092,10 +1098,10 @@
var arrow = self.attachAsset('arrow', {
y: PLANT_BUTTON_OFFSET / 2,
anchorX: 0.5,
anchorY: 0.5,
- scaleX: 2,
- scaleY: 2
+ scaleX: 1.4,
+ scaleY: 1.4
});
;
self.buttonBackground.y = PLANT_BUTTON_OFFSET;
self.imageAsset.y = PLANT_BUTTON_OFFSET;
@@ -1199,10 +1205,10 @@
var self = ConfigContainer.call(this, config);
var fruitGraphics = self.attachAsset(fruitName, {
anchorX: 0.5,
anchorY: 0.5,
- scaleX: PLANT_FRUIT_SCALE * Math.random() < 0.5 ? 1 : -1,
- scaleY: PLANT_FRUIT_SCALE
+ scaleX: SCALE_FRUIT_DROP * Math.random() < 0.5 ? 1 : -1,
+ scaleY: SCALE_FRUIT_DROP
});
;
self.fruitName = fruitName;
self.update = update;
@@ -1227,27 +1233,9 @@
var traderGraphics = self.attachAsset('trader', {
anchorX: 0.5,
anchorY: 0.5
});
- var trade = setTrade;
- if (!trade) {
- var details = PLANET_DETAILS[planet.name];
- var sellList = details.sell;
- var sellName = sellList[Math.floor(Math.random() * sellList.length)];
- var sellValue = FRUIT_DETAILS[sellName];
- var buyList = details.buy.filter(function (item) {
- return item !== sellName;
- });
- var buyName = buyList[Math.floor(Math.random() * sellList.length)];
- var buyValue = FRUIT_DETAILS[buyName];
- trade = {
- sellName: sellName,
- sellAmount: 0,
- // TEMP
- buyName: buyName,
- buyAmount: 0 // TEMP
- };
- }
+ 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
}));
@@ -1264,8 +1252,36 @@
self.destroy();
traders[index] = undefined;
}
}
+ function generateTrade() {
+ // Determine what the trade items are
+ var details = PLANET_DETAILS[planet.name];
+ var buyList = details.buy;
+ var buyName = buyList[Math.floor(Math.random() * buyList.length)];
+ var buyValue = buyName !== 'credits' ? FRUIT_DETAILS[buyName] : 1;
+ var sellList = details.sell.filter(function (item) {
+ return item !== buyName;
+ });
+ var sellName = buyList[Math.floor(Math.random() * sellList.length)];
+ // Determine trade value
+ var valueFactor = 1 + TRADER_COST_VARIANCE * (Math.random() * 2 - 1);
+ var buyValue = buyName !== 'credits' ? FRUIT_DETAILS[buyName] : 1;
+ var sellValue = valueFactor * (sellName !== 'credits' ? FRUIT_DETAILS[sellName] : 1);
+ // Determine quantities
+ var quantityFactor = TRADER_INVENTORY_MIN + Math.random() * (TRADER_INVENTORY_MAX - TRADER_INVENTORY_MIN);
+ var sellAmount = Math.round(quantityFactor * (sellName !== 'credits' ? inventory.getQuantity(sellName) : money));
+ var buyAmount = Math.max(1, Math.ceil(buyValue / (sellAmount * sellValue)));
+ sellAmount = Math.max(1, Math.round(buyAmount * buyValue / sellValue));
+ var trade = {
+ sellName: sellName,
+ sellAmount: sellAmount,
+ buyName: buyName,
+ buyAmount: buyAmount
+ };
+ console.log(trade);
+ return trade;
+ }
function checkValue(name, amount) {
if (name === 'credits') {
return money >= amount;
} else {
@@ -1322,19 +1338,17 @@
return tradeSymbols.addChild(new SymbolText(amount, 'currencySymbol', {
x: config.x,
anchorX: config.anchorX,
anchorY: 0.5,
- suffix: true,
- scale: 0.5,
tint: true
}));
} else {
return tradeSymbols.addChild(new SymbolText(amount + '×', name, {
x: config.x,
anchorX: config.anchorX,
anchorY: 0.5,
suffix: true,
- scale: 0.5
+ scale: SCALE_FRUIT_TRADE
}));
}
}
;
@@ -1401,14 +1415,20 @@
var ROCKET_FLAME_LIFETIME = 30;
var ROCKET_FLAME_SPEED = 5;
;
// Farm constants
-var PLOT_SIZE = 65;
-var PLOT_GAP = 90;
+var PLOT_SIZE = 80;
+var PLOT_GAP = 120;
+var PLOT_NODE_OFFSET = 20;
+var PLOT_FARM_OFFSET = -30;
var PLOT_ALPHA_STEP = 1 / GAME_TICKS;
var PLOT_EXTRA_LINGER = Math.floor(GAME_TICKS / 2);
;
// Interface settings
+var SCALE_FRUIT_DROP = 0.8;
+var SCALE_FRUIT_INVENTORY = 0.5;
+var SCALE_FRUIT_TRADE = 0.65;
+var SCALE_FRUIT_PLANTER = 0.4;
var TEXT_WINNING_OFFSET = 300;
var TEXT_SIZE_SMALL = 35;
var CROSSHAIR_DIST = 40;
var CROSSHAIR_VARIANCE = 10;
@@ -1440,14 +1460,14 @@
var PLAYER_BUFFER_SQRDIST = PLAYER_BUFFER_DIST * PLAYER_BUFFER_DIST;
var PLAYER_START_ANGLE = Math.PI / 16;
;
// Trader settings
-var TRADER_TIME_INITIAL = 10 * GAME_TICKS;
-var TRADER_TIME_BASE = 2 * GAME_TICKS;
-var TRADER_TIME_VARIANCE = 2 * 60 * GAME_TICKS;
+var TRADER_TIME_INITIAL = 15 * GAME_TICKS;
+var TRADER_TIME_BASE = 10 * GAME_TICKS;
+var TRADER_TIME_VARIANCE = 80 * 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_INVENTORY_MIN = 0.25;
+var TRADER_INVENTORY_MAX = 1.5;
var TRADER_FRAME_OFFSET_X = 0.1;
var TRADER_FRAME_OFFSET_Y = -0.56;
var TRADER_DETAIL_MARGIN = 20;
var TRADER_SHIP_SPACING = 50;
@@ -1459,9 +1479,9 @@
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_GENERAL = 'This cannot grow on this plant';
-var PLANT_GROWTH_FACTOR = 0.25;
+var PLANT_GROWTH_FACTOR = 0.1;
var PLANT_BUTTON_OFFSET = -220;
var PLANT_FRUIT_SCALE = 0.6;
var PLANT_DETAILS = {
plantWeeds: {
@@ -1528,9 +1548,9 @@
type: 'red',
plant: 'plantEyeball'
},
fruitFlower: {
- value: 50,
+ value: 20,
type: 'blue',
plant: 'plantFlower'
},
fruitDiamondDust: {
@@ -1549,45 +1569,45 @@
var NAVIGATION = ['planetGrey', 'planetRed', 'planetBlue', 'planetOmni', 'planetGold'];
var PLANET_DETAILS = {
planetGrey: {
cost: 0,
- radius: 200,
+ radius: 250,
spin: 0.001,
blueprint: PlanetGrey,
plantTypes: ['green'],
buy: ['credits', 'fruitBush', 'fruitStalk'],
sell: ['credits', 'fruitWeeds', 'fruitBush']
},
planetRed: {
cost: 100,
- radius: 400,
+ radius: 300,
spin: -0.0002,
blueprint: PlanetRed,
plantTypes: ['green', 'red'],
buy: ['credits', 'fruitStalk', 'fruitEyeball'],
sell: ['credits', 'fruitWeeds', 'fruitBush', 'fruitStalk', 'fruitEyeball']
},
planetBlue: {
cost: 250,
- radius: 350,
+ radius: 300,
spin: 0.001,
blueprint: PlanetBlue,
plantTypes: ['green', 'blue'],
buy: ['credits', 'fruitFlower'],
sell: ['credits', 'fruitWeeds', 'fruitBush', 'fruitFlower']
},
planetOmni: {
cost: 800,
- radius: 500,
- spin: 0.005,
+ radius: 200,
+ spin: 0.0005,
blueprint: PlanetOmni,
plantTypes: ['green', 'blue', 'red', 'omni'],
buy: ['credits'],
sell: ['fruitStalk', 'fruitEyeball', 'fruitFlower', 'fruitDiamond', 'fruitDiamond']
},
planetGold: {
cost: 3000,
- radius: 250,
+ radius: 150,
spin: -0.001,
blueprint: PlanetGold,
plantTypes: [],
buy: [],
@@ -1717,9 +1737,9 @@
}
}
if (available.length > 0) {
var spawnIndex = Math.floor(Math.random() * available.length);
- traders[i] = foreground.addChild(new Trader({
+ traders[spawnIndex] = foreground.addChild(new Trader({
index: spawnIndex,
x: GAME_WIDTH / 4 * (spawnIndex % 2 === 0 ? 1 : 3),
y: GAME_HEIGHT / 8 * (spawnIndex < 2 ? 2 : 7)
}, nextTrade));
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.