Add more planets
This commit is contained in:
parent
504f5fcc0c
commit
6cad5551bb
13 changed files with 748 additions and 23 deletions
|
@ -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'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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 + ')';
|
||||
|
|
|
@ -17,7 +17,6 @@ export function init() {
|
|||
clear();
|
||||
spawn.player();
|
||||
let p = spawn.startPlanet();
|
||||
spawn.testEntity(p);
|
||||
spawn.tick();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue