Fix issues

This commit is contained in:
schmelczerandras 2020-11-09 10:33:20 +01:00
parent 7cf33b9f1a
commit a4bab29d84
7 changed files with 30 additions and 14 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "declared-server", "name": "declared-server",
"version": "0.0.13", "version": "0.0.15",
"description": "Game server for decla.red", "description": "Game server for decla.red",
"keywords": [], "keywords": [],
"author": "András Schmelczer <andras@schmelczer.dev> (https://schmelczer.dev/)", "author": "András Schmelczer <andras@schmelczer.dev> (https://schmelczer.dev/)",

View file

@ -4,7 +4,7 @@ export const defaultOptions: Options = {
port: 3000, port: 3000,
name: 'Test server', name: 'Test server',
playerLimit: 16, playerLimit: 16,
npcCount: 12, npcCount: 16,
seed: Math.random(), seed: Math.random(),
scoreLimit: 1000, scoreLimit: 1000,
worldSize: 8000, worldSize: 8000,

View file

@ -1,5 +1,11 @@
import { vec2 } from 'gl-matrix'; import { vec2 } from 'gl-matrix';
import { Circle, CommandReceiver, GameObject, serializesTo } from 'shared'; import {
Circle,
CommandExecutors,
CommandReceiver,
GameObject,
serializesTo,
} from 'shared';
import { BoundingBox } from '../physics/bounding-boxes/bounding-box'; import { BoundingBox } from '../physics/bounding-boxes/bounding-box';
import { BoundingBoxBase } from '../physics/bounding-boxes/bounding-box-base'; import { BoundingBoxBase } from '../physics/bounding-boxes/bounding-box-base';
import { moveCircle } from '../physics/functions/move-circle'; import { moveCircle } from '../physics/functions/move-circle';
@ -17,6 +23,10 @@ export class CirclePhysical extends CommandReceiver implements Circle, DynamicPh
private _boundingBox: BoundingBox; private _boundingBox: BoundingBox;
protected commandExecutors: CommandExecutors = {
[ReactToCollisionCommand.type]: this.onCollision.bind(this),
};
constructor( constructor(
private _center: vec2, private _center: vec2,
private _radius: number, private _radius: number,

View file

@ -153,7 +153,7 @@ export class PlanetPhysical extends PlanetBase implements StaticPhysical {
public getForce(position: vec2): vec2 { public getForce(position: vec2): vec2 {
const diff = vec2.subtract(vec2.create(), this.center, position); const diff = vec2.subtract(vec2.create(), this.center, position);
const dist = Math.max(0, vec2.length(diff) - 600); const dist = Math.max(0, vec2.length(diff) - this.radius);
vec2.normalize(diff, diff); vec2.normalize(diff, diff);
const scale = clamp( const scale = clamp(
settings.maxGravityQ * ((settings.maxGravityDistance / dist) ** 1.5 - 1), settings.maxGravityQ * ((settings.maxGravityDistance / dist) ** 1.5 - 1),

View file

@ -82,6 +82,7 @@ export class JoinFormHandler {
if (response?.ok) { if (response?.ok) {
const content: ServerInformation = await response.json(); const content: ServerInformation = await response.json();
if (!this.servers.find((s) => s.url === url)) {
const server = new ServerChooserOption( const server = new ServerChooserOption(
content, content,
url, url,
@ -92,6 +93,7 @@ export class JoinFormHandler {
this.joinButton.disabled = false; this.joinButton.disabled = false;
this.container.appendChild(server.element); this.container.appendChild(server.element);
} }
}
}); });
} }

View file

@ -8,6 +8,7 @@ import { Id } from '../../communication/id';
@serializable @serializable
export class PlanetBase extends GameObject { export class PlanetBase extends GameObject {
public readonly center: vec2; public readonly center: vec2;
public readonly radius: number;
constructor( constructor(
id: Id, id: Id,
@ -17,6 +18,9 @@ export class PlanetBase extends GameObject {
super(id); super(id);
this.center = vertices.reduce((sum, v) => vec2.add(sum, sum, v), vec2.create()); this.center = vertices.reduce((sum, v) => vec2.add(sum, sum, v), vec2.create());
vec2.scale(this.center, this.center, 1 / vertices.length); vec2.scale(this.center, this.center, 1 / vertices.length);
this.radius =
vertices.reduce((sum, v) => sum + vec2.distance(this.center, v), 0) /
this.vertices.length;
} }
public generatedPoints(value: number) {} public generatedPoints(value: number) {}

View file

@ -27,7 +27,7 @@ export const settings = {
maxGravityQ: 5000, maxGravityQ: 5000,
planetControlThreshold: 0.2, planetControlThreshold: 0.2,
playerMaxHealth: 100, playerMaxHealth: 100,
maxGravityStrength: 10000, maxGravityStrength: 50000,
maxAcceleration: 120000, maxAcceleration: 120000,
playerMaxStrength: 80, playerMaxStrength: 80,
endGameDeltaScaling: 2, endGameDeltaScaling: 2,