Add server screen

This commit is contained in:
schmelczerandras 2020-10-16 23:26:03 +02:00
parent 89fafeafd3
commit e2129bbb26
20 changed files with 672 additions and 174 deletions

View file

@ -0,0 +1,3 @@
export interface PlayerInformation {
name: string;
}

View file

@ -0,0 +1,7 @@
export interface ServerInformation {
playerLimit: number;
playerCount: number;
serverName: string;
}
export const serverInformationEndpoint = '/stats';

View file

@ -25,6 +25,8 @@ export * from './helper/rectangle';
export * from './helper/mix';
export * from './helper/random';
export * from './helper/id';
export * from './communication/server-information';
export * from './communication/player-information';
export * from './helper/rotate-90-deg';
export * from './helper/rotate-minus-90-deg';
export * from './objects/game-object';

View file

@ -1,4 +1,6 @@
import { vec2 } from 'gl-matrix';
import { Random } from '../../helper/random';
import { settings } from '../../settings';
import { Id } from '../../transport/identity';
import { serializable } from '../../transport/serialization/serializable';
import { GameObject } from '../game-object';
@ -9,6 +11,30 @@ export class PlanetBase extends GameObject {
super(id);
}
public static createPlanetVertices(
center: vec2,
width: number,
height: number,
randomness: number,
vertexCount = settings.polygonEdgeCount,
): Array<vec2> {
const vertices = [];
for (let i = 0; i < vertexCount; i++) {
vertices.push(
vec2.fromValues(
center.x +
(width / 2) * Math.cos((i / vertexCount) * -Math.PI * 2) +
Random.getRandomInRange(-randomness, randomness),
center.y +
(height / 2) * Math.sin((i / vertexCount) * -Math.PI * 2) +
Random.getRandomInRange(-randomness, randomness),
),
);
}
return vertices;
}
public toArray(): Array<any> {
return [this.id, this.vertices];
}

View file

@ -13,5 +13,6 @@
"module": "commonjs",
"composite": true,
"lib": ["dom", "es2017"]
}
},
"include": ["src/**/*.ts"]
}