Add start of ship rendering

This commit is contained in:
asraelite 2018-03-03 00:04:17 +00:00
parent 4a253b0184
commit 704c82838a
15 changed files with 199 additions and 13 deletions

View file

@ -1,5 +1,5 @@
import * as game from './index.mjs';
export function startGame() {
console.log('started');
game.changeView('game');
}

View file

@ -2,15 +2,15 @@ import * as graphics from '../graphics/index.mjs';
import * as gui from '../gui/index.mjs';
import * as assets from '../assets.mjs';
import * as input from '../input.mjs';
import * as world from '../world/index.mjs';
import * as events from './events.mjs';
export let game;
export let state;
export async function init() {
game = {
state: {
room: 'menu',
paused: false
}
state = {
view: 'menu',
paused: false
};
graphics.init();
@ -18,6 +18,8 @@ export async function init() {
gui.init();
input.init();
//events.startGame();
// Recursive `requestAnimationFrame` can cause problems with Parcel.
while(true) {
await tick();
@ -25,7 +27,17 @@ export async function init() {
}
}
export function changeView(view) {
state.view = view;
gui.changeView(view);
if (view == 'game') {
world.init();
}
}
async function tick() {
if (state.view == 'game') world.tick();
gui.tick();
graphics.render();
input.tick();