summaryrefslogtreecommitdiff
path: root/engine/Game.ts
diff options
context:
space:
mode:
authorElizabeth (Lizzy) Hunt <elizabeth.hunt@simponic.xyz>2023-08-26 17:57:05 -0600
committerGitHub <noreply@github.com>2023-08-26 17:57:05 -0600
commit8a4ab8d79b5ce1dabb431168398b5d5111fe326c (patch)
treee60767dc5295edf379cf421e20171dc418e548b7 /engine/Game.ts
parentc6e9baa0009f7cce0f6ff156a3957ef04a8cb684 (diff)
parent6ce6946a4401d2ee6fa5cb747fab7d4c658a63c8 (diff)
downloadjumpstorm-8a4ab8d79b5ce1dabb431168398b5d5111fe326c.tar.gz
jumpstorm-8a4ab8d79b5ce1dabb431168398b5d5111fe326c.zip
Merge pull request #1 from Simponic/network
Network
Diffstat (limited to 'engine/Game.ts')
-rw-r--r--engine/Game.ts22
1 files changed, 11 insertions, 11 deletions
diff --git a/engine/Game.ts b/engine/Game.ts
index 07d06e8..cdd3507 100644
--- a/engine/Game.ts
+++ b/engine/Game.ts
@@ -1,5 +1,5 @@
-import { Entity } from "./entities";
-import { System } from "./systems";
+import { Entity } from './entities';
+import { System } from './systems';
export class Game {
private systemOrder: string[];
@@ -7,9 +7,9 @@ export class Game {
private running: boolean;
private lastTimeStamp: number;
- public entities: Map<number, Entity>;
+ public entities: Map<string, Entity>;
public systems: Map<string, System>;
- public componentEntities: Map<string, Set<number>>;
+ public componentEntities: Map<string, Set<string>>;
constructor() {
this.lastTimeStamp = performance.now();
@@ -29,17 +29,17 @@ export class Game {
this.entities.set(entity.id, entity);
}
- public getEntity(id: number): Entity | undefined {
+ public getEntity(id: string): Entity | undefined {
return this.entities.get(id);
}
- public removeEntity(id: number) {
+ public removeEntity(id: string) {
this.entities.delete(id);
}
public forEachEntityWithComponent(
componentName: string,
- callback: (entity: Entity) => void,
+ callback: (entity: Entity) => void
) {
this.componentEntities.get(componentName)?.forEach((entityId) => {
const entity = this.getEntity(entityId);
@@ -60,7 +60,7 @@ export class Game {
return this.systems.get(name);
}
- public doGameLoop = (timeStamp: number) => {
+ public doGameLoop(timeStamp: number) {
if (!this.running) {
return;
}
@@ -75,16 +75,16 @@ export class Game {
if (!this.componentEntities.has(component.name)) {
this.componentEntities.set(
component.name,
- new Set<number>([entity.id]),
+ new Set<string>([entity.id])
);
return;
}
this.componentEntities.get(component.name)?.add(entity.id);
- }),
+ })
);
this.systemOrder.forEach((systemName) => {
this.systems.get(systemName)?.update(dt, this);
});
- };
+ }
}