diff --git a/dist/img/celestials/green_2.svg b/dist/img/celestials/green_2.svg
new file mode 100644
index 0000000..c74842c
--- /dev/null
+++ b/dist/img/celestials/green_2.svg
@@ -0,0 +1,185 @@
+
+
+
+
diff --git a/dist/img/celestials/lava_0.svg b/dist/img/celestials/lava_0.svg
new file mode 100644
index 0000000..fc29ebf
--- /dev/null
+++ b/dist/img/celestials/lava_0.svg
@@ -0,0 +1,207 @@
+
+
+
+
diff --git a/dist/img/celestials/rock_0.svg b/dist/img/celestials/rock_0.svg
new file mode 100644
index 0000000..fdb4c29
--- /dev/null
+++ b/dist/img/celestials/rock_0.svg
@@ -0,0 +1,143 @@
+
+
+
+
diff --git a/dist/img/celestials/rock_1.svg b/dist/img/celestials/rock_1.svg
new file mode 100644
index 0000000..ac4c0a4
--- /dev/null
+++ b/dist/img/celestials/rock_1.svg
@@ -0,0 +1,172 @@
+
+
+
+
diff --git a/js/assets.mjs b/js/assets.mjs
index 789b46f..c343ee9 100644
--- a/js/assets.mjs
+++ b/js/assets.mjs
@@ -49,7 +49,11 @@ export const images = {
celestials: {
green: {
'0': 'celestials/green_0.svg',
- '1': 'celestials/green_1.svg'
+ '1': 'celestials/green_1.svg',
+ '2': 'celestials/green_2.svg',
+ '3': 'celestials/rock_0.svg',
+ '4': 'celestials/rock_1.svg',
+ '5': 'celestials/lava_0.svg'
}
}
};
diff --git a/js/consts.mjs b/js/consts.mjs
index 6bc3ca8..5240da8 100644
--- a/js/consts.mjs
+++ b/js/consts.mjs
@@ -24,7 +24,7 @@ export const TIP_ANGLE = 0.25;
export const TIP_SPEED = 0.03;
export const CRASH_SPEED = 0.7;
// Ship flight mechanics. Speed measured in units per tick.
-export const FUEL_BURN_RATE = 0.3;
+export const FUEL_BURN_RATE = 0.5;
export const THRUST_POWER = 0.004;
export const TURN_POWER = 0.07;
// Distance at which an orbited planet will not be considered a parent body.
diff --git a/js/game/events.mjs b/js/game/events.mjs
index fe770e4..21b8035 100644
--- a/js/game/events.mjs
+++ b/js/game/events.mjs
@@ -104,6 +104,8 @@ export function crash() {
}
export function gameOver(reason) {
+ if (game.state.editing)
+ endEditing();
gameOverReason = reason;
game.state.gameOver = true;
game.state.inventory = false;
diff --git a/js/game/index.mjs b/js/game/index.mjs
index 2f1b845..ea27cff 100644
--- a/js/game/index.mjs
+++ b/js/game/index.mjs
@@ -28,13 +28,7 @@ export async function init() {
events.playMusic();
//events.startGame();
- //tick(); return;
-
- // Recursive `requestAnimationFrame` can cause problems with Parcel.
- while(true) {
- tick();
- await new Promise(res => requestAnimationFrame(res));
- }
+ loop(tick);
}
export function changeView(view) {
@@ -56,6 +50,24 @@ export function changeView(view) {
}
}
+function loop(fn, fps = 60) {
+ let then = Date.now();
+ let interval = 1000 / fps;
+
+ (function loop(time) {
+ requestAnimationFrame(loop);
+
+ // again, Date.now() if it's available
+ let now = Date.now();
+ let delta = now - then;
+
+ if (delta > interval) {
+ then = now - (delta % interval);
+ fn();
+ }
+ })(0);
+};
+
function tick() {
events.tick();
diff --git a/js/game/inventory.mjs b/js/game/inventory.mjs
index 3336f0c..b5972da 100644
--- a/js/game/inventory.mjs
+++ b/js/game/inventory.mjs
@@ -14,10 +14,6 @@ let onupdate = () => {};
export function init() {
items.clear();
- addItem('connector', 'xheavy');
- addItem('connector', 'xheavy');
- addItem('connector', 'xheavy');
- addItem('connector', 'xheavy');
}
export function canToss() {
diff --git a/js/gui/modules.mjs b/js/gui/modules.mjs
index 73417d0..b77bb3d 100644
--- a/js/gui/modules.mjs
+++ b/js/gui/modules.mjs
@@ -106,8 +106,9 @@ export function game() {
editButton.posRelative({ x: 0.5, xc: 0.5, y: 1 });
editButton.y -= 45;
editButton.tick = () => {
- editButton.options.draw = state.landed;
- editButton.options.disabled = state.editing && editMessage !== '';
+ let usable = state.landed && !state.gameOver;
+ editButton.options.draw = usable;
+ editButton.options.disabled = usable && editMessage !== '';
if (state.editing) {
editButton.text = 'Finish';
if (editMessage !== '') editButton.text = '(' + editMessage + ')';
diff --git a/js/world/index.mjs b/js/world/index.mjs
index 3bbc327..902498d 100644
--- a/js/world/index.mjs
+++ b/js/world/index.mjs
@@ -17,7 +17,6 @@ export function init() {
clear();
spawn.player();
let p = spawn.startPlanet();
- spawn.testEntity(p);
spawn.tick();
}
diff --git a/js/world/ship.mjs b/js/world/ship.mjs
index 05d0f1c..e10b7e9 100644
--- a/js/world/ship.mjs
+++ b/js/world/ship.mjs
@@ -223,10 +223,13 @@ export default class Ship extends Body {
this.applyDirectionalForce(0, thrustForce, turnForce);
+ if (Math.abs(this.rvel) > 0.1) {
+ this.rvel *= 0.7;
+ }
+
this.modules.forEach(m => {
if (m.type !== 'thruster' || thrustForce == 0) return;
m.power += forward;
});
-
}
}
diff --git a/js/world/spawn.mjs b/js/world/spawn.mjs
index cca2264..db2f1d2 100644
--- a/js/world/spawn.mjs
+++ b/js/world/spawn.mjs
@@ -139,18 +139,19 @@ export function player() {
}
export function startPlanet() {
- return randomPlanet(0, 0, {
+ let planet = randomPlanet(0, 0, {
radius: 40,
density: 3,
type: 'green'
});
+ let fuel = new Entity(0, 0, 'fuelcan');
+ world.entities.add(fuel);
+ fuel.orbit(planet, 10, -0.5);
+ return planet;
}
-export function testEntity(parent) {
- let entity = new Entity(0, -50);
- world.entities.add(entity);
- entity.orbit(parent, 10);
- return entity;
+export function startEntity(parent) {
+
}
export function celestial(x, y, radius, params) {