diff --git a/frontend/.dockerignore b/frontend/.dockerignore deleted file mode 100644 index 2044e20..0000000 --- a/frontend/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -Dockerfile -node_modules -dist -package-lock.json -.* diff --git a/frontend/src/scripts/physics/commands/move-to.ts b/frontend/src/scripts/commands/move-to.ts similarity index 81% rename from frontend/src/scripts/physics/commands/move-to.ts rename to frontend/src/scripts/commands/move-to.ts index 1e9810f..f762b3c 100644 --- a/frontend/src/scripts/physics/commands/move-to.ts +++ b/frontend/src/scripts/commands/move-to.ts @@ -1,5 +1,5 @@ import { vec2 } from 'gl-matrix'; -import { Command } from '../../commands/command'; +import { Command } from './command'; export class MoveToCommand extends Command { public constructor(public readonly position?: vec2) { diff --git a/frontend/src/scripts/graphics/commands/render.ts b/frontend/src/scripts/commands/render.ts similarity index 81% rename from frontend/src/scripts/graphics/commands/render.ts rename to frontend/src/scripts/commands/render.ts index 5c0cc8d..0a05d7a 100644 --- a/frontend/src/scripts/graphics/commands/render.ts +++ b/frontend/src/scripts/commands/render.ts @@ -1,5 +1,5 @@ import { Renderer } from 'sdf-2d'; -import { Command } from '../../commands/command'; +import { Command } from './command'; export class RenderCommand extends Command { public constructor(public readonly renderer?: Renderer) { diff --git a/frontend/src/scripts/physics/commands/step.ts b/frontend/src/scripts/commands/step.ts similarity index 80% rename from frontend/src/scripts/physics/commands/step.ts rename to frontend/src/scripts/commands/step.ts index 301597c..4fa2291 100644 --- a/frontend/src/scripts/physics/commands/step.ts +++ b/frontend/src/scripts/commands/step.ts @@ -1,4 +1,4 @@ -import { Command } from '../../commands/command'; +import { Command } from './command'; export class StepCommand extends Command { public constructor(public readonly deltaTimeInMiliseconds?: DOMHighResTimeStamp) { diff --git a/frontend/src/scripts/physics/commands/teleport-to.ts b/frontend/src/scripts/commands/teleport-to.ts similarity index 81% rename from frontend/src/scripts/physics/commands/teleport-to.ts rename to frontend/src/scripts/commands/teleport-to.ts index 46d1758..9f0b942 100644 --- a/frontend/src/scripts/physics/commands/teleport-to.ts +++ b/frontend/src/scripts/commands/teleport-to.ts @@ -1,5 +1,5 @@ import { vec2 } from 'gl-matrix'; -import { Command } from '../../commands/command'; +import { Command } from './command'; export class TeleportToCommand extends Command { public constructor(public readonly position?: vec2) { diff --git a/frontend/src/scripts/game.ts b/frontend/src/scripts/game.ts index a3634b7..3001782 100644 --- a/frontend/src/scripts/game.ts +++ b/frontend/src/scripts/game.ts @@ -1,7 +1,10 @@ import { vec2 } from 'gl-matrix'; import { CircleLight, compile, Flashlight, InvertedTunnel, Renderer } from 'sdf-2d'; import { CommandBroadcaster } from './commands/command-broadcaster'; -import { RenderCommand } from './graphics/commands/render'; +import { MoveToCommand } from './commands/move-to'; +import { RenderCommand } from './commands/render'; +import { StepCommand } from './commands/step'; +import { TeleportToCommand } from './commands/teleport-to'; import { DeltaTimeCalculator } from './helper/delta-time-calculator'; import { prettyPrint } from './helper/pretty-print'; import { rgb } from './helper/rgb'; @@ -14,12 +17,9 @@ import { Camera } from './objects/types/camera'; import { Character } from './objects/types/character'; import { createDungeon } from './objects/world/create-dungeon'; import { BoundingBoxBase } from './physics/bounds/bounding-box-base'; -import { MoveToCommand } from './physics/commands/move-to'; -import { StepCommand } from './physics/commands/step'; -import { TeleportToCommand } from './physics/commands/teleport-to'; import { Physics } from './physics/physics'; import { settings } from './settings'; -import { BlobShape } from './shapes/types/blob-shape'; +import { BlobShape } from './shapes/blob-shape'; export class Game implements IGame { public readonly objects = new Objects(); @@ -45,10 +45,22 @@ export class Game implements IGame { this.rendererPromise = compile( canvas, [ - InvertedTunnel.descriptor, - Flashlight.descriptor, - BlobShape.descriptor, - CircleLight.descriptor, + { + ...InvertedTunnel.descriptor, + shaderCombinationSteps: [0, 2, 4, 8, 16], + }, + { + ...Flashlight.descriptor, + shaderCombinationSteps: [0, 1], + }, + { + ...BlobShape.descriptor, + shaderCombinationSteps: [0, 1], + }, + { + ...CircleLight.descriptor, + shaderCombinationSteps: [0, 1, 2, 4, 8, 16], + }, ], { shadowTraceCount: 12, @@ -90,7 +102,9 @@ export class Game implements IGame { private initializeScene() { createDungeon(this.objects, this.physics); - //createDungeon(this.objects, this.physics); + createDungeon(this.objects, this.physics); + createDungeon(this.objects, this.physics); + createDungeon(this.objects, this.physics); this.character = new Character(this.physics, this); this.objects.addObject(this.character); diff --git a/frontend/src/scripts/objects/types/camera.ts b/frontend/src/scripts/objects/types/camera.ts index 5bd1c32..13c5948 100644 --- a/frontend/src/scripts/objects/types/camera.ts +++ b/frontend/src/scripts/objects/types/camera.ts @@ -1,9 +1,9 @@ import { vec2 } from 'gl-matrix'; -import { RenderCommand } from '../../graphics/commands/render'; +import { MoveToCommand } from '../../commands/move-to'; +import { RenderCommand } from '../../commands/render'; import { CursorMoveCommand } from '../../input/commands/cursor-move-command'; import { ZoomCommand } from '../../input/commands/zoom'; import { BoundingBox } from '../../physics/bounds/bounding-box'; -import { MoveToCommand } from '../../physics/commands/move-to'; import { GameObject } from '../game-object'; export class Camera extends GameObject { diff --git a/frontend/src/scripts/objects/types/lamp.ts b/frontend/src/scripts/objects/types/lamp.ts index 1817f80..e961cd4 100644 --- a/frontend/src/scripts/objects/types/lamp.ts +++ b/frontend/src/scripts/objects/types/lamp.ts @@ -1,9 +1,9 @@ import { vec2, vec3 } from 'gl-matrix'; import { CircleLight } from 'sdf-2d'; -import { RenderCommand } from '../../graphics/commands/render'; +import { MoveToCommand } from '../../commands/move-to'; +import { RenderCommand } from '../../commands/render'; import { BoundingBoxBase } from '../../physics/bounds/bounding-box-base'; import { ImmutableBoundingBox } from '../../physics/bounds/immutable-bounding-box'; -import { MoveToCommand } from '../../physics/commands/move-to'; import { PhysicalObject } from '../../physics/physical-object'; import { Physics } from '../../physics/physics'; import { settings } from '../../settings'; diff --git a/frontend/src/scripts/objects/types/tunnel.ts b/frontend/src/scripts/objects/types/tunnel.ts index 60f1758..28988a9 100644 --- a/frontend/src/scripts/objects/types/tunnel.ts +++ b/frontend/src/scripts/objects/types/tunnel.ts @@ -1,13 +1,13 @@ import { vec2 } from 'gl-matrix'; -import { RenderCommand } from '../../graphics/commands/render'; +import { InvertedTunnel } from 'sdf-2d'; +import { RenderCommand } from '../../commands/render'; import { BoundingBoxBase } from '../../physics/bounds/bounding-box-base'; import { ImmutableBoundingBox } from '../../physics/bounds/immutable-bounding-box'; import { Physics } from '../../physics/physics'; import { StaticPhysicalObject } from '../../physics/static-physical-object'; -import { TunnelShape } from '../../shapes/types/tunnel-shape'; export class Tunnel extends StaticPhysicalObject { - private shape: TunnelShape; + private shape: InvertedTunnel; constructor( physics: Physics, @@ -17,7 +17,7 @@ export class Tunnel extends StaticPhysicalObject { toRadius: number ) { super(physics, true); - this.shape = new TunnelShape(from, to, fromRadius, toRadius); + this.shape = new InvertedTunnel(from, to, fromRadius, toRadius); this.addToPhysics(); this.addCommandExecutor(RenderCommand, this.draw.bind(this)); diff --git a/frontend/src/scripts/settings.ts b/frontend/src/scripts/settings.ts index 15c28bb..f2ab3c7 100644 --- a/frontend/src/scripts/settings.ts +++ b/frontend/src/scripts/settings.ts @@ -1,3 +1,5 @@ export const settings = { lightCutoffDistance: 600, + hitDetectionCirclePointCount: 8, + hitDetectionMaxOverlap: 0.01, }; diff --git a/frontend/src/scripts/shapes/types/blob-shape.ts b/frontend/src/scripts/shapes/blob-shape.ts similarity index 97% rename from frontend/src/scripts/shapes/types/blob-shape.ts rename to frontend/src/scripts/shapes/blob-shape.ts index 365e74e..cb06cd4 100644 --- a/frontend/src/scripts/shapes/types/blob-shape.ts +++ b/frontend/src/scripts/shapes/blob-shape.ts @@ -1,6 +1,6 @@ import { mat2d, vec2 } from 'gl-matrix'; import { Drawable, DrawableDescriptor } from 'sdf-2d'; -import { BoundingCircle } from '../../physics/bounds/bounding-circle'; +import { BoundingCircle } from '../physics/bounds/bounding-circle'; export class BlobShape extends Drawable { public static descriptor: DrawableDescriptor = { diff --git a/frontend/src/scripts/shapes/types/circle-shape.ts b/frontend/src/scripts/shapes/types/circle-shape.ts deleted file mode 100644 index 158b468..0000000 --- a/frontend/src/scripts/shapes/types/circle-shape.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { vec2 } from 'gl-matrix'; -import { Circle } from 'sdf-2d'; -import { GameObject } from '../../objects/game-object'; - -export class CircleShape extends Circle { - public constructor( - center = vec2.create(), - radius = 0, - public readonly gameObject: GameObject = null - ) { - super(center, radius); - } - - public clone(): CircleShape { - return new CircleShape(vec2.clone(this.center), this.radius, this.gameObject); - } -} diff --git a/frontend/src/scripts/shapes/types/tunnel-shape.ts b/frontend/src/scripts/shapes/types/tunnel-shape.ts deleted file mode 100644 index 8e3b977..0000000 --- a/frontend/src/scripts/shapes/types/tunnel-shape.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { vec2 } from 'gl-matrix'; -import { InvertedTunnel } from 'sdf-2d'; - -export class TunnelShape extends InvertedTunnel { - constructor(from: vec2, to: vec2, fromRadius: number, toRadius: number) { - super(from, to, fromRadius, toRadius); - } - - public clone(): TunnelShape { - return new TunnelShape( - vec2.clone(this.from), - vec2.clone(this.to), - this.fromRadius, - this.toRadius - ); - } -}