Add more planets
This commit is contained in:
parent
504f5fcc0c
commit
6cad5551bb
13 changed files with 748 additions and 23 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue