summaryrefslogtreecommitdiff
path: root/engine/structures
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-25 16:48:17 -0600
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-25 16:48:17 -0600
commit773ce84f4bf559337e132edd7fcce02a0a2598fd (patch)
tree5fd0b452b459cc5a5b6a1ed98f2d7b9af950864d /engine/structures
parentdec7b614d895a1b507137e4a96a8999ff63aa179 (diff)
downloadjumpstorm-773ce84f4bf559337e132edd7fcce02a0a2598fd.tar.gz
jumpstorm-773ce84f4bf559337e132edd7fcce02a0a2598fd.zip
prettier formatting
Diffstat (limited to 'engine/structures')
-rw-r--r--engine/structures/Grid.ts16
-rw-r--r--engine/structures/QuadTree.ts22
-rw-r--r--engine/structures/RefreshingCollisionFinderBehavior.ts10
-rw-r--r--engine/structures/index.ts6
4 files changed, 27 insertions, 27 deletions
diff --git a/engine/structures/Grid.ts b/engine/structures/Grid.ts
index 6e8c0cb..5f0e053 100644
--- a/engine/structures/Grid.ts
+++ b/engine/structures/Grid.ts
@@ -1,6 +1,6 @@
-import type { Coord2D, Dimension2D } from "../interfaces";
-import type { BoxedEntry, RefreshingCollisionFinderBehavior } from ".";
-import { Miscellaneous } from "../config/constants";
+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[]>;
@@ -12,11 +12,11 @@ export class Grid implements RefreshingCollisionFinderBehavior {
constructor(
gridDimension: Dimension2D = {
width: Miscellaneous.WIDTH,
- height: Miscellaneous.HEIGHT,
+ height: Miscellaneous.HEIGHT
},
cellDimension: Dimension2D = {
width: Miscellaneous.DEFAULT_GRID_WIDTH,
- height: Miscellaneous.DEFAULT_GRID_HEIGHT,
+ height: Miscellaneous.DEFAULT_GRID_HEIGHT
},
topLeft = { x: 0, y: 0 }
) {
@@ -73,7 +73,7 @@ export class Grid implements RefreshingCollisionFinderBehavior {
const translated: Coord2D = {
y: center.y - this.topLeft.y,
- x: center.x - this.topLeft.x,
+ x: center.x - this.topLeft.x
};
const topLeftBox = {
@@ -82,7 +82,7 @@ export class Grid implements RefreshingCollisionFinderBehavior {
),
y: Math.floor(
(translated.y - dimension.height / 2) / this.cellDimension.height
- ),
+ )
};
const bottomRightBox = {
x: Math.floor(
@@ -90,7 +90,7 @@ export class Grid implements RefreshingCollisionFinderBehavior {
),
y: Math.floor(
(translated.y + dimension.height / 2) / this.cellDimension.height
- ),
+ )
};
const cells: number[] = [];
diff --git a/engine/structures/QuadTree.ts b/engine/structures/QuadTree.ts
index 1ab2d1d..93702d0 100644
--- a/engine/structures/QuadTree.ts
+++ b/engine/structures/QuadTree.ts
@@ -1,11 +1,11 @@
-import type { Coord2D, Dimension2D } from "../interfaces";
-import type { BoxedEntry, RefreshingCollisionFinderBehavior } from ".";
+import type { Coord2D, Dimension2D } from '../interfaces';
+import type { BoxedEntry, RefreshingCollisionFinderBehavior } from '.';
enum Quadrant {
I,
II,
III,
- IV,
+ IV
}
/*
@@ -102,8 +102,8 @@ export class QuadTree implements RefreshingCollisionFinderBehavior {
[Quadrant.III, { x: this.topLeft.x, y: this.topLeft.y + halfHeight }],
[
Quadrant.IV,
- { x: this.topLeft.x + halfWidth, y: this.topLeft.y + halfHeight },
- ],
+ { x: this.topLeft.x + halfWidth, y: this.topLeft.y + halfHeight }
+ ]
] as [Quadrant, Coord2D][]
).forEach(([quadrant, pos]) => {
this.children.set(
@@ -122,27 +122,27 @@ export class QuadTree implements RefreshingCollisionFinderBehavior {
private getQuadrants(boxedEntry: BoxedEntry): Quadrant[] {
const treeCenter: Coord2D = {
x: this.topLeft.x + this.dimension.width / 2,
- y: this.topLeft.y + this.dimension.height / 2,
+ y: this.topLeft.y + this.dimension.height / 2
};
return (
[
[
Quadrant.I,
- (x: number, y: number) => x >= treeCenter.x && y < treeCenter.y,
+ (x: number, y: number) => x >= treeCenter.x && y < treeCenter.y
],
[
Quadrant.II,
- (x: number, y: number) => x < treeCenter.x && y < treeCenter.y,
+ (x: number, y: number) => x < treeCenter.x && y < treeCenter.y
],
[
Quadrant.III,
- (x: number, y: number) => x < treeCenter.x && y >= treeCenter.y,
+ (x: number, y: number) => x < treeCenter.x && y >= treeCenter.y
],
[
Quadrant.IV,
- (x: number, y: number) => x >= treeCenter.x && y >= treeCenter.y,
- ],
+ (x: number, y: number) => x >= treeCenter.x && y >= treeCenter.y
+ ]
] as [Quadrant, (x: number, y: number) => boolean][]
)
.filter(
diff --git a/engine/structures/RefreshingCollisionFinderBehavior.ts b/engine/structures/RefreshingCollisionFinderBehavior.ts
index 21d690d..573ddd8 100644
--- a/engine/structures/RefreshingCollisionFinderBehavior.ts
+++ b/engine/structures/RefreshingCollisionFinderBehavior.ts
@@ -1,4 +1,4 @@
-import type { Coord2D, Dimension2D } from "../interfaces";
+import type { Coord2D, Dimension2D } from '../interfaces';
export interface BoxedEntry {
id: string;
@@ -7,8 +7,8 @@ export interface BoxedEntry {
}
export interface RefreshingCollisionFinderBehavior {
- public clear(): void;
- public insert(boxedEntry: BoxedEntry): void;
- public getNeighborIds(boxedEntry: BoxedEntry): Set<string>;
- public setTopLeft(topLeft: Coord2d): void;
+ clear(): void;
+ insert(boxedEntry: BoxedEntry): void;
+ getNeighborIds(boxedEntry: BoxedEntry): Set<string>;
+ setTopLeft(topLeft: Coord2D): void;
}
diff --git a/engine/structures/index.ts b/engine/structures/index.ts
index 49a84af..679dbd4 100644
--- a/engine/structures/index.ts
+++ b/engine/structures/index.ts
@@ -1,3 +1,3 @@
-export * from "./RefreshingCollisionFinderBehavior";
-export * from "./QuadTree";
-export * from "./Grid";
+export * from './RefreshingCollisionFinderBehavior';
+export * from './QuadTree';
+export * from './Grid';