Fix issues
This commit is contained in:
parent
7cf33b9f1a
commit
a4bab29d84
7 changed files with 30 additions and 14 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "declared-server",
|
||||
"version": "0.0.13",
|
||||
"version": "0.0.15",
|
||||
"description": "Game server for decla.red",
|
||||
"keywords": [],
|
||||
"author": "András Schmelczer <andras@schmelczer.dev> (https://schmelczer.dev/)",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export const defaultOptions: Options = {
|
|||
port: 3000,
|
||||
name: 'Test server',
|
||||
playerLimit: 16,
|
||||
npcCount: 12,
|
||||
npcCount: 16,
|
||||
seed: Math.random(),
|
||||
scoreLimit: 1000,
|
||||
worldSize: 8000,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
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 { BoundingBoxBase } from '../physics/bounding-boxes/bounding-box-base';
|
||||
import { moveCircle } from '../physics/functions/move-circle';
|
||||
|
|
@ -17,6 +23,10 @@ export class CirclePhysical extends CommandReceiver implements Circle, DynamicPh
|
|||
|
||||
private _boundingBox: BoundingBox;
|
||||
|
||||
protected commandExecutors: CommandExecutors = {
|
||||
[ReactToCollisionCommand.type]: this.onCollision.bind(this),
|
||||
};
|
||||
|
||||
constructor(
|
||||
private _center: vec2,
|
||||
private _radius: number,
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ export class PlanetPhysical extends PlanetBase implements StaticPhysical {
|
|||
|
||||
public getForce(position: vec2): vec2 {
|
||||
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);
|
||||
const scale = clamp(
|
||||
settings.maxGravityQ * ((settings.maxGravityDistance / dist) ** 1.5 - 1),
|
||||
|
|
|
|||
|
|
@ -82,15 +82,17 @@ export class JoinFormHandler {
|
|||
|
||||
if (response?.ok) {
|
||||
const content: ServerInformation = await response.json();
|
||||
const server = new ServerChooserOption(
|
||||
content,
|
||||
url,
|
||||
this.removeServer.bind(this),
|
||||
this.servers.length === 0,
|
||||
);
|
||||
this.servers.push(server);
|
||||
this.joinButton.disabled = false;
|
||||
this.container.appendChild(server.element);
|
||||
if (!this.servers.find((s) => s.url === url)) {
|
||||
const server = new ServerChooserOption(
|
||||
content,
|
||||
url,
|
||||
this.removeServer.bind(this),
|
||||
this.servers.length === 0,
|
||||
);
|
||||
this.servers.push(server);
|
||||
this.joinButton.disabled = false;
|
||||
this.container.appendChild(server.element);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { Id } from '../../communication/id';
|
|||
@serializable
|
||||
export class PlanetBase extends GameObject {
|
||||
public readonly center: vec2;
|
||||
public readonly radius: number;
|
||||
|
||||
constructor(
|
||||
id: Id,
|
||||
|
|
@ -17,6 +18,9 @@ export class PlanetBase extends GameObject {
|
|||
super(id);
|
||||
this.center = vertices.reduce((sum, v) => vec2.add(sum, sum, v), vec2.create());
|
||||
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) {}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export const settings = {
|
|||
maxGravityQ: 5000,
|
||||
planetControlThreshold: 0.2,
|
||||
playerMaxHealth: 100,
|
||||
maxGravityStrength: 10000,
|
||||
maxGravityStrength: 50000,
|
||||
maxAcceleration: 120000,
|
||||
playerMaxStrength: 80,
|
||||
endGameDeltaScaling: 2,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue