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
Code edit (4 edits merged)
Please save this source code
User prompt
Add an LK.timeout of 500ms before creating the player in the ship
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
The TraderDialogue's setTint should flash the dialogueBackground object the tint colour for 500ms
Code edit (9 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -530,8 +530,95 @@
var self = Plant.call(this, 'plantDiamond', growthStage, potted, config);
;
self.strong = true;
});
+var Fruit = ConfigContainer.expand(function (fruitName, config) {
+ var self = ConfigContainer.call(this, config);
+ var falling = true;
+ var fruitGraphics = self.attachAsset(fruitName, {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: SCALE_FRUIT_DROP * (Math.random() < 0.5 ? 1 : -1),
+ scaleY: SCALE_FRUIT_DROP
+ });
+ ;
+ self.fruitName = fruitName;
+ self.update = update;
+ ;
+ function update() {
+ // Check if fruit is within collection range
+ if (player) {
+ var dx = self.x - player.x;
+ var dy = self.y - player.y;
+ var sqrDistance = dx * dx + dy * dy;
+ if (sqrDistance < PLAYER_ACTION_SQRDIST) {
+ inventory.adjustItem(fruitName, 1);
+ stats.cropsHarvested++;
+ var popupEffect = popupMap[fruitName];
+ if (!popupEffect) {
+ var rotation = player.rotation + MATH_HALF_PI;
+ var offset = planet.radius + POPUP_OFFSET;
+ popupEffect = new PopupEffect(fruitName, {
+ x: Math.cos(rotation) * offset,
+ y: Math.sin(rotation) * offset,
+ rotation: rotation
+ });
+ } else {
+ popupEffect.increment();
+ }
+ return true;
+ }
+ }
+ // Handle fruit falling towards the planet
+ if (falling) {
+ var angle = self.rotation + MATH_HALF_PI;
+ self.x += Math.cos(angle) * FRUIT_FALL_SPEED;
+ self.y += Math.sin(angle) * FRUIT_FALL_SPEED;
+ if (self.x * self.x + self.y * self.y <= planet.radius * planet.radius) {
+ falling = false;
+ }
+ }
+ }
+ ;
+ planet.fruitList.push(planet.addChild(self));
+ return self;
+});
+var PopupEffect = ConfigContainer.expand(function (fruitName, config) {
+ var self = ConfigContainer.call(this, config);
+ var count = 1;
+ var lifetime = POPUP_DURATION;
+ var symbolText = self.addChild(new SymbolText(count + '×', fruitName, {
+ anchorX: 0.5,
+ anchorY: 1,
+ suffix: true,
+ scale: SCALE_FRUIT_TRADE
+ }));
+ ;
+ self.update = update;
+ self.increment = increment;
+ ;
+ function update() {
+ if (--lifetime > 0) {
+ symbolText.y -= 1;
+ symbolText.alpha = lifetime / POPUP_DURATION;
+ if (lifetime === POPUP_RECYCLE) {
+ popupMap[fruitName] = undefined;
+ }
+ } else {
+ self.destroy();
+ return true;
+ }
+ }
+ ;
+ function increment() {
+ count++;
+ symbolText.setText(count + '×');
+ }
+ ;
+ effectsList.push(planet.addChild(self));
+ popupMap[fruitName] = self;
+ return self;
+});
var PlantNode = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
;
self.update = update;
@@ -1244,52 +1331,8 @@
}
;
effectsList.push(self);
});
-var Fruit = ConfigContainer.expand(function (fruitName, config) {
- var self = ConfigContainer.call(this, config);
- var falling = true;
- var fruitGraphics = self.attachAsset(fruitName, {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: SCALE_FRUIT_DROP * (Math.random() < 0.5 ? 1 : -1),
- scaleY: SCALE_FRUIT_DROP
- });
- ;
- self.fruitName = fruitName;
- self.update = update;
- ;
- function update() {
- // Check if fruit is within collection range
- if (player) {
- var dx = self.x - player.x;
- var dy = self.y - player.y;
- var sqrDistance = dx * dx + dy * dy;
- if (sqrDistance < PLAYER_ACTION_SQRDIST) {
- inventory.adjustItem(fruitName, 1);
- stats.cropsHarvested++;
- // Create a PopupEffect above the player
- var popupEffect = new PopupEffect(fruitName, {
- x: player.x,
- y: player.y - player.height / 2
- });
- effectsList.push(game.addChild(popupEffect));
- return true;
- }
- }
- // Handle fruit falling towards the planet
- if (falling) {
- var angle = self.rotation + MATH_HALF_PI;
- self.x += Math.cos(angle) * FRUIT_FALL_SPEED;
- self.y += Math.sin(angle) * FRUIT_FALL_SPEED;
- if (self.x * self.x + self.y * self.y <= planet.radius * planet.radius) {
- falling = false;
- }
- }
- }
- ;
- planet.fruitList.push(planet.addChild(self));
-});
var Trader = ConfigContainer.expand(function (config, setTrade) {
var self = ConfigContainer.call(this, config);
var index = config.index;
var angle = Math.random() * MATH_2_PI;
@@ -1500,25 +1543,9 @@
y: TRADER_DETAIL_MARGIN / 2,
anchorX: config.anchorX,
anchorY: 0
}));
-});
-var PopupEffect = ConfigContainer.expand(function (fruitName, config) {
- var self = ConfigContainer.call(this, config);
- var symbolText = self.addChild(new SymbolText(fruitName, '', {
- anchorX: 0.5,
- anchorY: 0.5
- }));
- var lifetime = 60; // 1 second at 60FPS
- self.update = function () {
- if (--lifetime > 0) {
- symbolText.y -= 1;
- symbolText.alpha = lifetime / 60;
- } else {
- self.destroy();
- return true;
- }
- };
+ ;
return self;
});
/****
@@ -1587,8 +1614,11 @@
var TEXT_SIZE_LARGE = 75;
var CROSSHAIR_DIST = 40;
var CROSSHAIR_VARIANCE = 10;
var CROSSHAIR_PERIOD = 1.25 * GAME_TICKS / MATH_2_PI;
+var POPUP_OFFSET = 150;
+var POPUP_DURATION = 1 * GAME_TICKS;
+var POPUP_RECYCLE = Math.floor(POPUP_DURATION * 0.5);
;
// Inventory settings
var INVENTORY_ROWS = 1;
var INVENTORY_COLS = 7;
@@ -1788,8 +1818,10 @@
;
var money = 10000;
var planetMap = {};
var asteroidList = [];
+var effectsList = [];
+var popupMap = {};
var stats = {
creditsEarned: 0,
cropsPlanted: 0,
cropsHarvested: 0,
@@ -1804,9 +1836,8 @@
var winningStats = {};
var winningTick = -1;
var winningTime = '';
var winningMessage;
-var effectsList = [];
var player;
var traders = [];
var traderCountdown = TRADER_TIME_INITIAL;
var 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.