Add basic multiplayer

This commit is contained in:
schmelczerandras 2020-10-05 19:07:17 +02:00
parent 0f0a1eaf67
commit 46a48e7c15
113 changed files with 1362 additions and 754 deletions

View file

@ -1,29 +1,13 @@
import { glMatrix } from 'gl-matrix';
import io from 'socket.io-client';
import { TransportEvents } from '../../shared/src/transport/transport-events';
import { Configuration } from './scripts/config/configuration';
import { Game } from './scripts/game';
import { Random } from './scripts/helper/random';
import './styles/main.scss';
glMatrix.setMatrixArrayType(Array);
Random.seed = 42;
const main = async () => {
await Configuration.initialize();
const socket = io(Configuration.servers[0], {
reconnectionDelayMax: 10000,
transports: ['websocket'],
});
socket.on('reconnect_attempt', () => {
socket.io.opts.transports = ['polling', 'websocket'];
});
socket.emit(TransportEvents.PlayerJoining, null);
try {
Random.seed = 42;
await new Game().start();
} catch (e) {
console.error(e);