Code edit (12 edits merged)
Please save this source code
User prompt
Instead of calling `planet.update()` in the onTick callback, iterate through the planetMap object and update all planets
Code edit (1 edits merged)
Please save this source code
Code edit (17 edits merged)
Please save this source code
User prompt
add a global PLANT_DEAD_COLOUR variable which is a hex-tint for brown
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Create a new UprootButton class that has the same logic as the PlanterButton
User prompt
Duplicate the PlanterButton as UprootButton and PlanterButton classes
Code edit (9 edits merged)
Please save this source code
User prompt
Please remove PLOT_EXTRA_LINGER
Code edit (4 edits merged)
Please save this source code
User prompt
When collecting a fruit, create a PopupEffect (adding it to the effectsList) above the player
User prompt
create a PopupEffect class inheriting from the ConfigContainer class and taking in a fruitName and config params. The class contains a SymbolText element which slowly increases it's y value and disappears after 1 second
Code edit (1 edits merged)
Please save this source code
User prompt
after performing the player collection check, fruit should fall towards the planet at a fixed rate, stopping when it reaches the planet's radius distance
User prompt
fruit should fall towards the planet at a fixed rate
Code edit (9 edits merged)
Please save this source code
User prompt
In the planterButtonCallback function, instead of setting the targetPoint to 0, set targetPoint to the angle between the planet and the self's positions
Code edit (1 edits merged)
Please save this source code
User prompt
When a fruit is collected, increment the cropsHarvested stat
User prompt
When the trader buttoncallback is called, increment the salesRejected stat if the accepted param is false, otherwise increment the salesDone stat if it was fully completed
User prompt
When an asteroid impacts the planet, increase the stats.asteroidImpacts value by 1
Code edit (10 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: trader.handleTradeCallback is not a function' in or related to this line: 'trader.handleTradeCallback(false);' Line Number: 1946
===================================================================
--- original.js
+++ change.js
@@ -362,8 +362,9 @@
});
var Plant = ConfigContainer.expand(function (type, growthStage, potted, config) {
var self = ConfigContainer.call(this, config);
var details = PLANT_DETAILS[type];
+ var scale = 1 + randomFloatInRange(-PLANT_SCALE_VARIANCE, PLANT_SCALE_VARIANCE);
;
self.update = update;
self.uproot = uproot;
self.action = action;
@@ -447,9 +448,10 @@
}
self.graphics = self.createAsset(self.type + self.growthStage, {
anchorX: 0.5,
anchorY: 1,
- scaleX: Math.random() < 0.5 ? 1 : -1
+ scaleX: scale * Math.random() < 0.5 ? 1 : -1,
+ scaleY: scale
});
}
function refreshCountdown() {
var baseTime = self.growthTime + Math.random() * self.growthVariance;
@@ -460,13 +462,15 @@
});
var PlantWeeds = Plant.expand(function (growthStage, potted, config) {
var self = Plant.call(this, 'plantWeeds', growthStage, potted, config);
var baseUpdate = self.update;
+ var baseHarvest = self.harvest;
var baseUpdateStage = self.updateStage;
var spreadCountdown = 0;
;
self.update = update;
self.action = action;
+ self.harvest = harvest;
self.updateStage = updateStage;
self.strong = true;
self.actionable = !potted;
self.uprootable = potted;
@@ -495,15 +499,19 @@
}
}
function action() {
if (self.actionable) {
- stats.weedsPulled++;
self.harvest();
self.parent.removePlant();
return true;
}
return false;
}
+ function harvest(quantity) {
+ baseHarvest(quantity);
+ ;
+ stats.weedsPulled++;
+ }
function updateStage(newStage) {
baseUpdateStage(newStage);
;
if (newStage === self.growthStages) {
@@ -610,36 +618,99 @@
return self;
});
var PlantStalk = Plant.expand(function (growthStage, potted, config) {
var self = Plant.call(this, 'plantStalk', growthStage, potted, config);
+ var baseUpdateStage = self.updateStage;
+ var yieldStage = 5;
+ var yieldPerStage = 3;
;
+ self.updateStage = updateStage;
self.skipFinalGrowth = true;
+ self.fruitOffsetMin = 200;
+ self.fruitOffsetMax = 300;
+ self.fruitRange = 30;
;
+ function updateStage(newStage) {
+ baseUpdateStage(newStage);
+ ;
+ if (newStage >= yieldStage) {
+ self.fruitCount += yieldPerStage;
+ }
+ if (newStage === self.growthStages) {
+ self.harvest();
+ self.parent.removePlant();
+ }
+ }
+ ;
self.updateStage(growthStage);
return self;
});
var PlantEyeball = Plant.expand(function (growthStage, potted, config) {
var self = Plant.call(this, 'plantEyeball', growthStage, potted, config);
+ var baseUpdateStage = self.updateStage;
+ var decorAmount = 3;
+ var decorScale = 0.5;
+ var fruitChance = 0.33;
+ var fruitChances = 20;
;
+ self.updateStage = updateStage;
self.skipFinalGrowth = true;
+ self.fruitOffsetMin = 80;
+ self.fruitOffsetMax = 140;
+ self.fruitRange = 20;
;
+ function updateStage(newStage) {
+ baseUpdateStage(newStage);
+ ;
+ if (newStage === self.growthStages) {
+ if (fruitChances-- > 0) {
+ if (Math.random() < fruitChance) {
+ self.harvest(self.fruitCount = 1);
+ }
+ } else {
+ self.parent.removePlant();
+ }
+ } else if (newStage === self.growthStages - 1) {
+ createVisuals();
+ }
+ }
+ function createVisuals() {
+ for (var i = 0; i < decorAmount; i++) {
+ var decorOffset = randomFloatInRange(self.fruitOffsetMin, self.fruitOffsetMax);
+ var rangeRotation = Math.random() * MATH_2_PI;
+ var rangeDistance = Math.random() * self.fruitRange;
+ var decorX = self.x + Math.cos(rangeRotation) * rangeDistance;
+ var decorY = self.y - decorOffset + Math.sin(rangeRotation) * rangeDistance;
+ self.attachAsset(self.fruit, {
+ x: decorX,
+ y: decorY,
+ scaleX: decorScale,
+ scaleY: decorScale
+ });
+ }
+ }
+ ;
self.updateStage(growthStage);
return self;
});
var PlantFlower = Plant.expand(function (growthStage, potted, config) {
var self = Plant.call(this, 'plantFlower', growthStage, potted, config);
var baseUpdateStage = self.updateStage;
- var yieldStages = 4;
+ var yieldStage = 4;
+ var fruitYFactor = 0.75;
var fruitCount = 4;
;
self.action = action;
self.updateStage = updateStage;
+ self.fruitRange = 50;
;
function action() {
if (self.actionable) {
self.harvest();
self.parent.removePlant();
+ return true;
}
+ return false;
}
function updateStage(newStage) {
baseUpdateStage(newStage);
;
@@ -648,23 +719,47 @@
self.fruitCount = Math.round(Math.random());
self.graphics.tint = PLANT_DEAD_COLOUR;
self.actionable = false;
self.uprootable = true;
- } else if (newStage >= self.growthStages - yieldStages) {
+ } else if (newStage >= yieldStage) {
// Harvestable plant/flower
self.fruitCount = fruitCount + Math.round(Math.random());
self.actionable = true;
+ self.fruitOffsetMin = self.graphics.height * fruitYFactor;
+ self.fruitOffsetMax = self.graphics.height * fruitYFactor;
}
}
;
self.updateStage(growthStage);
return self;
});
var PlantDiamond = Plant.expand(function (growthStage, potted, config) {
var self = Plant.call(this, 'plantDiamond', growthStage, potted, config);
+ var baseUpdateStage = self.updateStage;
;
+ self.action = action;
+ self.updateStage = updateStage;
self.strong = true;
+ self.fruitOffsetMin = 123;
+ self.fruitOffsetMax = 123;
;
+ function action() {
+ if (self.actionable) {
+ self.harvest();
+ self.parent.removePlant();
+ return true;
+ }
+ return false;
+ }
+ function updateStage(newStage) {
+ baseUpdateStage(newStage);
+ ;
+ if (newStage === self.growthStages) {
+ self.fruitCount = 1;
+ self.actionable = true;
+ }
+ }
+ ;
self.updateStage(growthStage);
return self;
});
var Fruit = ConfigContainer.expand(function (fruitName, config) {
@@ -960,9 +1055,11 @@
;
function update(ticks) {
self.rotation += self.spin;
updateList(nodes);
- updateList(fruitList);
+ if (planet === self) {
+ updateList(fruitList);
+ }
}
function createNodes() {
if (!self.barren) {
var defaultPlant = 'plantWeeds';
@@ -1594,11 +1691,12 @@
buyAmount = randomInt(TRADER_FRUIT_OFFER_MIN, TRADER_FRUIT_OFFER_MAX);
sellAmount = Math.round(buyAmount * value);
} else if (buyName === 'credits') {
// Player selling Fruit for Credits
+ var minSell = details.minSell || TRADER_MINIMUM_BUY;
var value = valueFactor * FRUIT_DETAILS[sellName].value;
var quantity = Math.max(1, inventory.getQuantity(sellName));
- sellAmount = Math.max(TRADER_MINIMUM_BUY, randomInt(quantity * TRADER_INVENTORY_MIN, quantity * TRADER_INVENTORY_MAX));
+ sellAmount = Math.max(minSell, randomInt(quantity * TRADER_INVENTORY_MIN, quantity * TRADER_INVENTORY_MAX));
buyAmount = Math.round(sellAmount * value);
} else {
// Fruit exchange
var multiplier = 1 + Math.random() * (TRADER_EXCHANGE_MULTIPLIER - 1);
@@ -1750,8 +1848,9 @@
var TEXT_DEFAULT_SIZE = 50; // Required by: BorderedText, SymbolText
var TEXT_DEFAULT_MARGIN = 0; // Required by: SymbolText
;
// Game constants
+var GAME_TESTING = true;
var GAME_TICKS = 60;
var GAME_WIDTH = 2048;
var GAME_HEIGHT = 2732;
var GAME_SPEED = 0.1;
@@ -1848,9 +1947,10 @@
var GROW_WARNING_BARREN = 'Nothing grows on this planet';
var GROW_WARNING_GENERAL = 'This cannot grow on this planet';
var GROW_WARNING_DIAMOND = 'This cannot be planted, only sold';
var FRUIT_FALL_SPEED = 3;
-var PLANT_GROWTH_FACTOR = 0.1;
+var PLANT_SCALE_VARIANCE = 0.05;
+var PLANT_GROWTH_FACTOR = 0.4;
var PLANT_DEAD_COLOUR = 0x964B00;
var PLANT_DETAILS = {
plantWeeds: {
blueprint: PlantWeeds,
@@ -1911,14 +2011,14 @@
type: 'red',
plant: 'plantStalk'
},
fruitEyeball: {
- value: 15,
+ value: 10,
type: 'red',
plant: 'plantEyeball'
},
fruitFlower: {
- value: 25,
+ value: 15,
type: 'blue',
plant: 'plantFlower'
},
fruitDiamondDust: {
@@ -1926,9 +2026,10 @@
type: 'omni',
plant: 'plantDiamond'
},
fruitDiamond: {
- value: 250
+ value: 500,
+ minSell: 1
}
};
;
// Planet & navigation settings
@@ -1944,27 +2045,27 @@
buy: ['credits', 'credits', 'fruitBush', 'fruitStalk'],
sell: ['credits', 'fruitWeeds', 'fruitBush']
},
planetRed: {
- cost: 100,
+ cost: 150,
radius: 300,
spin: -0.0002,
blueprint: PlanetRed,
plantTypes: ['green', 'red'],
buy: ['credits', 'credits', 'fruitStalk', 'fruitEyeball'],
sell: ['credits', 'fruitWeeds', 'fruitBush', 'fruitStalk', 'fruitEyeball']
},
planetBlue: {
- cost: 250,
+ cost: 500,
radius: 250,
spin: 0.001,
blueprint: PlanetBlue,
plantTypes: ['green', 'blue'],
buy: ['credits', 'credits', 'fruitFlower'],
sell: ['credits', 'fruitWeeds', 'fruitBush', 'fruitFlower']
},
planetOmni: {
- cost: 800,
+ cost: 2000,
radius: 350,
spin: -0.0005,
coarse: true,
blueprint: PlanetOmni,
@@ -1972,9 +2073,9 @@
buy: ['credits'],
sell: ['fruitStalk', 'fruitEyeball', 'fruitFlower', 'fruitDiamond', 'fruitDiamond']
},
planetGold: {
- cost: 3000,
+ cost: 8500,
radius: 150,
spin: -0.002,
barren: true,
blueprint: PlanetGold,
@@ -1987,9 +2088,9 @@
//==============================================================================
// Global variables
//==============================================================================
;
-var money = 10000;
+var money = 20;
var planetMap = {};
var asteroidList = [];
var effectsList = [];
var popupMap = {};
@@ -2052,8 +2153,19 @@
x: 0,
y: -100
}));
planetMap[planet.name] = planet;
+// Adjustments made purely for testing purposes
+if (GAME_TESTING) {
+ money = 10000;
+ PLANT_GROWTH_FACTOR = 0.1;
+ inventory.adjustItem('fruitWeeds', 10);
+ inventory.adjustItem('fruitBush', 10);
+ inventory.adjustItem('fruitStalk', 10);
+ inventory.adjustItem('fruitEyeball', 10);
+ inventory.adjustItem('fruitFlower', 10);
+ inventory.adjustItem('fruitDiamondDust', 10);
+}
;
//==============================================================================
// Gameplay events
//==============================================================================
@@ -2068,9 +2180,11 @@
if (player) {
player.update();
}
ship.update();
- planet.update();
+ for (var key in planetMap) {
+ planetMap[key].update();
+ }
crosshair.update();
updateList(effectsList);
for (var i = 0; i < 4; i++) {
var trader = traders[i];
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.