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