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
@@ -235,25 +235,33 @@
anchorY: 0.75
});
;
self.update = update;
+ self.currentAngle = 0;
;
function update() {
- var currentAngle = Math.atan2(self.y, self.x);
- var angleDifference = targetAngle - currentAngle;
- angleDifference = mod(angleDifference + Math.PI, MATH_2_PI) - Math.PI;
- if (angleDifference < -MATH_APPROX_ZERO || angleDifference > MATH_APPROX_ZERO) {
+ self.currentAngle = Math.atan2(self.y, self.x);
+ var angleDifference = mod(targetAngle - currentAngle + Math.PI, MATH_2_PI) - Math.PI;
+ if (approxZero(angleDifference)) {
+ if (taskLaunch) {
+ self.destroy();
+ player = undefined;
+ LK.setTimeout(function () {
+ ship.launch(1);
+ }, PLAYER_SPAWN_DELAY);
+ } else if (taskPlanter) {} else {
+ performAction(currentAngle);
+ actionCountdown = PLAYER_ACTION_INTERVAL;
+ }
+ } else if (--actionCountdown <= 0) {
var direction = angleDifference / Math.abs(angleDifference);
var angleStep = PLAYER_SPEED / planet.radius;
var newAngle = currentAngle + direction * Math.min(Math.abs(angleDifference), angleStep);
self.x = Math.cos(newAngle) * planet.radius;
self.y = Math.sin(newAngle) * planet.radius;
playerGraphics.scale.x = direction < 0 ? -1 : 1;
playerGraphics.rotation = newAngle + MATH_HALF_PI;
actionCountdown = 0; // Perform action immediately after stopping
- } else if (--actionCountdown <= 0) {
- actionCountdown = PLAYER_ACTION_INTERVAL;
- performAction(currentAngle);
}
}
function performAction(angle) {
var count = planet.nodes.length;
@@ -305,9 +313,9 @@
rotation: ship.rotation,
x: ship.x,
y: ship.y
}));
- }, 500);
+ }, PLAYER_SPAWN_DELAY);
}
} else if (self.direction > 0) {
counter++;
var speed = Math.pow(ROCKET_SPEED_BASE, counter / ROCKET_SPEED_DIV - ROCKET_SPEED_DELAY);
@@ -327,12 +335,8 @@
}
function launch(direction) {
if (!self.direction) {
self.direction = direction;
- if (direction > 0) {
- player.destroy();
- player = undefined;
- }
}
}
});
var FlameParticle = ConfigContainer.expand(function (config) {
@@ -826,10 +830,10 @@
if (self.unlocked) {
unlock();
}
});
-var NavigationInterface = Container.expand(function (x, y) {
- var self = Container.call(this);
+var NavigationInterface = ConfigContainer.expand(function (config) {
+ var self = ConfigContainer.call(this);
var buttons = {};
var baseOffset = -NAVIGATION.length / 2 + 0.5;
var firstPlanet = NAVIGATION[0];
for (var i = 0; i < NAVIGATION.length; i++) {
@@ -840,10 +844,9 @@
y: 0
}));
}
;
- self.x = x;
- self.y = y;
+ self.setDestination = setDestination;
;
function buttonCallback(planet) {
var button = buttons[planet];
if (button.unlocked) {
@@ -852,15 +855,18 @@
moneyDisplay.setText(money -= button.cost);
button.unlock();
}
}
- self.setDestination = setDestination;
- ;
function setDestination(planet) {
- if (destinationPlanet !== planet && ship.direction === 0) {
- destinationPlanet = planet;
+ if (player) {
buttons[planet].addChild(crosshair);
- ship.launch(1);
+ destinationPlanet = planet;
+ if (destinationPlanet !== planet) {
+ taskLaunch = true;
+ targetAngle = 0;
+ } else {
+ taskLaunch = false;
+ }
}
}
;
buttonCallback(firstPlanet);
@@ -1524,8 +1530,9 @@
var EXPLOSION_FRAMES = 15; // Number of frames for the explosion animation to last
;
// Player settings
var PLAYER_SPEED = 5;
+var PLAYER_SPAWN_DELAY = 500;
var PLAYER_ACTION_INTERVAL = Math.floor(GAME_TICKS / 4);
var PLAYER_ACTION_DIST = 80;
var PLAYER_ACTION_SQRDIST = PLAYER_ACTION_DIST * PLAYER_ACTION_DIST;
var PLAYER_BUFFER_DIST = 400;
@@ -1729,8 +1736,10 @@
};
var skipRetarget = false;
var retargetAngle;
var targetAngle = PLAYER_START_ANGLE;
+var taskLaunch = false;
+var taskPlanter = false;
var currentPlanet = NAVIGATION[0];
var destinationPlanet = NAVIGATION[0];
var background = game.addChild(new Background());
var midground = game.addChild(new Container());
@@ -1753,9 +1762,12 @@
anchorX: 0,
anchorY: .5
}));
var crosshair = new Crosshair();
-var navigation = LK.gui.bottom.addChild(new NavigationInterface(0, -100));
+var navigation = LK.gui.bottom.addChild(new NavigationInterface({
+ x: 0,
+ y: -100
+}));
planetMap[planet.name] = planet;
;
//==============================================================================
// Gameplay events
@@ -1795,8 +1807,13 @@
var dy = clickPosition.y - planet.y;
var sqrDistance = dx * dx + dy * dy;
var range = planet.radius + PLAYER_BUFFER_DIST;
if (sqrDistance <= range * range) {
+ if (taskLaunch) {
+ taskLaunch = false;
+ navigation.setDestination(currentPlanet);
+ }
+ taskPlanter = false;
retargetAngle = Math.atan2(dy, dx) - planet.rotation;
}
}
});
@@ -1888,17 +1905,21 @@
background.refresh();
inventory.refreshAllowed();
}
;
+function saveStats() {
+ for (var key in stats) {
+ winningStats[key] = stats[key];
+ }
+}
+;
function mod(x, base) {
return (x % base + base) % base;
}
;
function randomInt(min, max) {
return Math.floor(min + Math.random() * (max - min));
}
;
-function saveStats() {
- for (var key in stats) {
- winningStats[key] = stats[key];
- }
+function approxZero(value) {
+ return value > -MATH_APPROX_ZERO && value < MATH_APPROX_ZERO;
}
\ No newline at end of file
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.