Make physics more fun

This commit is contained in:
schmelczerandras 2020-10-16 11:48:52 +02:00
parent 155e360c8e
commit 89fafeafd3
41 changed files with 511 additions and 334 deletions

View file

@ -4,11 +4,14 @@ import { Command } from '../command';
@serializable
export class MoveActionCommand extends Command {
public constructor(public readonly direction: vec2) {
public constructor(
public readonly direction: vec2,
public readonly isCharacterRelative: boolean,
) {
super();
}
public toArray(): Array<any> {
return [this.direction];
return [this.direction, this.isCharacterRelative];
}
}

View file

@ -0,0 +1,3 @@
import { vec2 } from 'gl-matrix';
export const rotateMinus90Deg = (vec: vec2): vec2 => vec2.fromValues(vec.y, -vec.x);

View file

@ -26,6 +26,7 @@ export * from './helper/mix';
export * from './helper/random';
export * from './helper/id';
export * from './helper/rotate-90-deg';
export * from './helper/rotate-minus-90-deg';
export * from './objects/game-object';
export * from './transport/serialization/deserialize';
export * from './transport/serialization/serialize';
@ -34,7 +35,7 @@ export * from './transport/serialization/serializable';
export * from './transport/serialization/override-deserialization';
export * from './objects/types/character-base';
export * from './objects/types/lamp-base';
export * from './objects/types/stone-base';
export * from './objects/types/planet-base';
export * from './objects/types/projectile-base';
export * from './settings';
export * from './transport/transport-events';

View file

@ -4,7 +4,7 @@ import { serializable } from '../../transport/serialization/serializable';
import { GameObject } from '../game-object';
@serializable
export class StoneBase extends GameObject {
export class PlanetBase extends GameObject {
constructor(id: Id, public readonly vertices: Array<vec2>) {
super(id);
}

View file

@ -1,21 +1,25 @@
import { vec2 } from 'gl-matrix';
import { rgb255 } from './helper/rgb255';
export const settings = {
lightCutoffDistance: 600,
physicsMaxStep: 5,
gravitationalForce: vec2.fromValues(0, -3000),
maxVelocityX: 2000,
maxVelocityY: 3650,
polygonEdgeCount: 8,
projectileSpeed: 2000,
physicsMaxStep: 2,
maxVelocityX: 1000,
maxVelocityY: 1000,
polygonEdgeCount: 7,
maxGravityDistance: 700,
maxGravityQ: 180,
maxGravityStrength: 10000,
maxAcceleration: 10000,
projectileSpeed: 4000,
projectileMaxBounceCount: 1,
projectileStartOffset: 150,
projectileCreationInterval: 500,
projectileStartOffset: 250,
projectileCreationInterval: 0.1,
playerColorIndexOffset: 3,
worldLeftEdge: -5000,
worldRightEdge: 5000,
backgroundGradient: [rgb255(255, 117, 129), rgb255(136, 117, 255)],
worldTopEdge: 10000,
worldRightEdge: 10000,
worldLeftEdge: -10000,
worldBottomEdge: -10000,
backgroundGradient: [rgb255(90, 38, 43), rgb255(43, 39, 73)],
playerColors: [
rgb255(107, 48, 188),
rgb255(56, 254, 220),
@ -46,11 +50,8 @@ export const settings = {
rgb255(114, 73, 30),
rgb255(75, 75, 75),
],
maxAccelerationX: 2000000,
maxAccelerationY: 20500,
targetPhysicsDeltaTimeInMilliseconds: 20,
minPhysicsSleepTime: 4,
velocityAttenuation: 0.1,
velocityAttenuation: 0.25,
inViewAreaSize: 1920 * 1080 * 3,
defaultJumpEnergy: 0.25,
};