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
User prompt
Fix Bug: 'TypeError: mainAsset.fill is undefined' in or related to this line: 'mainAsset.fill.set(textFill = newFill);' Line Number: 110
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- 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.