Fix bugs and add improvements

This commit is contained in:
schmelczerandras 2020-10-13 12:47:25 +02:00
parent 555be9d602
commit ba4dd5c470
10 changed files with 26 additions and 21 deletions

View file

@ -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';

View file

@ -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,
};

View file

@ -2,11 +2,14 @@ import { serializableMapping } from './serializable-mapping';
export const deserialize = (json: string): any => {
return JSON.parse(json, (k, v) => {
const possibleType = v[0];
const overridableConstructor = serializableMapping.get(possibleType);
if (overridableConstructor) {
v.shift();
return new overridableConstructor.constructor(...v);
if (v !== null && Object.prototype.hasOwnProperty.call(v, '0')) {
const possibleType = v[0];
const overridableConstructor = serializableMapping.get(possibleType);
if (overridableConstructor) {
v.shift();
return new overridableConstructor.constructor(...v);
}
return v;
}
return v;
});