diff options
Diffstat (limited to 'engine')
-rw-r--r-- | engine/config/constants.ts | 5 | ||||
-rw-r--r-- | engine/structures/Grid.ts | 11 |
2 files changed, 13 insertions, 3 deletions
diff --git a/engine/config/constants.ts b/engine/config/constants.ts index 3d536d3..b3c3f62 100644 --- a/engine/config/constants.ts +++ b/engine/config/constants.ts @@ -11,7 +11,7 @@ export namespace KeyConstants { }; export const ActionKeys: Map<Action, string[]> = Object.keys( - KeyActions, + KeyActions ).reduce((acc: Map<Action, string[]>, key) => { const action = KeyActions[key]; @@ -36,4 +36,7 @@ export namespace PhysicsConstants { export namespace Miscellaneous { export const WIDTH = 600; export const HEIGHT = 800; + + export const DEFAULT_GRID_WIDTH = 40; + export const DEFAULT_GRID_HEIGHT = 40; } diff --git a/engine/structures/Grid.ts b/engine/structures/Grid.ts index 836aaf4..6e8c0cb 100644 --- a/engine/structures/Grid.ts +++ b/engine/structures/Grid.ts @@ -1,5 +1,6 @@ import type { Coord2D, Dimension2D } from "../interfaces"; import type { BoxedEntry, RefreshingCollisionFinderBehavior } from "."; +import { Miscellaneous } from "../config/constants"; export class Grid implements RefreshingCollisionFinderBehavior { private cellEntities: Map<number, string[]>; @@ -9,8 +10,14 @@ export class Grid implements RefreshingCollisionFinderBehavior { private topLeft: Coord2D; constructor( - gridDimension: Dimension2D, - cellDimension: Dimension2D, + gridDimension: Dimension2D = { + width: Miscellaneous.WIDTH, + height: Miscellaneous.HEIGHT, + }, + cellDimension: Dimension2D = { + width: Miscellaneous.DEFAULT_GRID_WIDTH, + height: Miscellaneous.DEFAULT_GRID_HEIGHT, + }, topLeft = { x: 0, y: 0 } ) { this.gridDimension = gridDimension; |