Fix bugs and add improvements
This commit is contained in:
parent
555be9d602
commit
ba4dd5c470
10 changed files with 26 additions and 21 deletions
|
|
@ -29,15 +29,15 @@ export const createDungeon = (objectContainer: PhysicalContainer) => {
|
|||
Random.getRandomInRange(0, height),
|
||||
);
|
||||
} while (
|
||||
calculateDistanceField(position) < 600 ||
|
||||
calculateDistanceField(position) < 800 ||
|
||||
calculateDistanceField(position) > 2000
|
||||
);
|
||||
|
||||
objects.push(
|
||||
createBlob(
|
||||
position,
|
||||
Random.getRandomInRange(200, 2000),
|
||||
Random.getRandomInRange(100, 500),
|
||||
Random.getRandomInRange(300, 800),
|
||||
Random.getRandomInRange(300, 800),
|
||||
Random.getRandomInRange(10, 40),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -160,6 +160,5 @@ export class Player extends CommandReceiver {
|
|||
this.isActive = false;
|
||||
freeColor(this.character.colorIndex);
|
||||
this.character.destroy();
|
||||
this.objects.removeObject(this.character);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ export class Game {
|
|||
}
|
||||
|
||||
private async setupRenderer(): Promise<void> {
|
||||
const noiseTexture = await renderNoise([64, 1], 20, 1 / 10);
|
||||
const noiseTexture = await renderNoise([256, 256], 2, 1 / 10);
|
||||
|
||||
this.renderer = await compile(
|
||||
this.canvas,
|
||||
|
|
@ -123,6 +123,7 @@ export class Game {
|
|||
overrides: {
|
||||
maxFilter: FilteringOptions.LINEAR,
|
||||
wrapS: WrapOptions.MIRRORED_REPEAT,
|
||||
wrapT: WrapOptions.MIRRORED_REPEAT,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -135,7 +136,7 @@ export class Game {
|
|||
}
|
||||
|
||||
public displayToWorldCoordinates(p: vec2): vec2 {
|
||||
return this.renderer.displayToWorldCoordinates(p);
|
||||
return this.renderer?.displayToWorldCoordinates(p);
|
||||
}
|
||||
|
||||
public aspectRatioChanged(aspectRatio: number) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export class ProjectileView extends ProjectileBase implements ViewObject {
|
|||
constructor(id: Id, center: vec2, radius: number) {
|
||||
super(id, center, radius);
|
||||
this.circle = new Circle(center, radius / 2);
|
||||
this.light = new CircleLight(center, rgb(1, 0.5, 0), 0.35);
|
||||
this.light = new CircleLight(center, rgb(1, 0.5, 0), 0.15);
|
||||
}
|
||||
|
||||
public step(deltaTimeInMilliseconds: number): void {}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { Drawable, Renderer } from 'sdf-2d';
|
||||
import { CommandExecutors, Id, StoneBase } from 'shared';
|
||||
import { CommandExecutors, Id, Random, StoneBase } from 'shared';
|
||||
import { RenderCommand } from '../commands/types/render';
|
||||
import { Polygon } from '../shapes/polygon';
|
||||
import { ViewObject } from './view-object';
|
||||
|
|
@ -14,10 +14,12 @@ export class StoneView extends StoneBase implements ViewObject {
|
|||
|
||||
constructor(id: Id, vertices: Array<vec2>) {
|
||||
super(id, vertices);
|
||||
this.shape = new Polygon(vertices);
|
||||
this.shape = new Polygon(vertices, Random.getRandom());
|
||||
}
|
||||
|
||||
public step(deltaTimeInMilliseconds: number): void {}
|
||||
public step(deltaTimeInMilliseconds: number): void {
|
||||
this.shape.randomOffset += deltaTimeInMilliseconds / 5000;
|
||||
}
|
||||
|
||||
public draw(renderer: Renderer): void {
|
||||
renderer.addDrawable(this.shape);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { PolygonFactory } from 'sdf-2d';
|
||||
import { NoisyPolygonFactory } from 'sdf-2d';
|
||||
import { settings } from 'shared';
|
||||
|
||||
export const Polygon = PolygonFactory(settings.polygonEdgeCount);
|
||||
export const Polygon = NoisyPolygonFactory(settings.polygonEdgeCount, 1);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export * from './helper/circle';
|
|||
export * from './helper/rectangle';
|
||||
export * from './helper/mix';
|
||||
export * from './helper/random';
|
||||
export * from './helper/unique';
|
||||
export * from './helper/id';
|
||||
export * from './helper/rotate-90-deg';
|
||||
export * from './objects/game-object';
|
||||
export * from './transport/serialization/deserialize';
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export const settings = {
|
|||
lightCutoffDistance: 600,
|
||||
physicsMaxStep: 5,
|
||||
gravitationalForce: vec2.fromValues(0, -3000),
|
||||
maxVelocityX: 4800,
|
||||
maxVelocityX: 2000,
|
||||
maxVelocityY: 3650,
|
||||
polygonEdgeCount: 8,
|
||||
projectileSpeed: 2000,
|
||||
|
|
@ -46,11 +46,11 @@ export const settings = {
|
|||
rgb255(114, 73, 30),
|
||||
rgb255(75, 75, 75),
|
||||
],
|
||||
maxAccelerationX: 200000,
|
||||
maxAccelerationX: 2000000,
|
||||
maxAccelerationY: 20500,
|
||||
targetPhysicsDeltaTimeInMilliseconds: 20,
|
||||
minPhysicsSleepTime: 4,
|
||||
velocityAttenuation: 0.33,
|
||||
velocityAttenuation: 0.1,
|
||||
inViewAreaSize: 1920 * 1080 * 3,
|
||||
defaultJumpEnergy: 0.25,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { serializableMapping } from './serializable-mapping';
|
|||
|
||||
export const deserialize = (json: string): any => {
|
||||
return JSON.parse(json, (k, v) => {
|
||||
if (v !== null && Object.prototype.hasOwnProperty.call(v, '0')) {
|
||||
const possibleType = v[0];
|
||||
const overridableConstructor = serializableMapping.get(possibleType);
|
||||
if (overridableConstructor) {
|
||||
|
|
@ -9,5 +10,7 @@ export const deserialize = (json: string): any => {
|
|||
return new overridableConstructor.constructor(...v);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
return v;
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue