Express

No description

fork
loading
Files
  • index.js
  • meta
  • public
  • server
  • views
  • map.json
  • package-lock.json
  • package.json
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const app 		 = require('./server/auth/site-serving.js');
const colyseus = require('colyseus');
const schema 	 = require('@colyseus/schema');
const http 	 	 = require('http');
const Player 	 = require('./server/classes/player.js');
const Room 		 = require('./server/colyseus/room.js');
const State 	 = require('./server/colyseus/state.js');
const dotenv   = require('dotenv').config();

const type = schema.type;
const gameServer = new colyseus.Server({
	server: http.createServer(app),
	express: app
});

type({ map: Player })(State.prototype, 'players');
type('number')(Player.prototype, 'x');
type('number')(Player.prototype, 'y');
type('number')(Player.prototype, 'angle');
type('number')(Player.prototype, 'health');
type('string')(Player.prototype, 'username');
type('string')(Player.prototype, 'color');
gameServer.define('hub', Room);

gameServer.listen(process.env.PORT || 0);
console.log('server started');