summaryrefslogtreecommitdiff
path: root/engine/components
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-13 16:47:58 -0600
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-13 16:47:58 -0600
commit98e795029bcc404463ed151ff5255a72498bc641 (patch)
tree48e50d896d00761eae18c89f89e5dd0ef353b660 /engine/components
parentc6e9baa0009f7cce0f6ff156a3957ef04a8cb684 (diff)
downloadjumpstorm-98e795029bcc404463ed151ff5255a72498bc641.tar.gz
jumpstorm-98e795029bcc404463ed151ff5255a72498bc641.zip
Create network component and system
Diffstat (limited to 'engine/components')
-rw-r--r--engine/components/BoundingBox.ts6
-rw-r--r--engine/components/NetworkUpdateable.ts7
-rw-r--r--engine/components/index.ts1
-rw-r--r--engine/components/names.ts1
4 files changed, 13 insertions, 2 deletions
diff --git a/engine/components/BoundingBox.ts b/engine/components/BoundingBox.ts
index 5e21b2f..19967f7 100644
--- a/engine/components/BoundingBox.ts
+++ b/engine/components/BoundingBox.ts
@@ -47,8 +47,9 @@ export class BoundingBox extends Component {
{ x: this.dimension.width / 2, y: this.dimension.height / 2 },
{ x: this.dimension.width / 2, y: -this.dimension.height / 2 },
]
- .map((vertex) => rotateVector(vertex, this.rotation))
+ .map((vertex) => rotateVector(vertex, this.rotation)) // rotate
.map((vertex) => {
+ // translate
return {
x: vertex.x + this.center.x,
y: vertex.y + this.center.y,
@@ -56,9 +57,10 @@ export class BoundingBox extends Component {
});
}
- public getRotationInPiOfUnitCircle() {
+ public getRotationInPiOfUnitCircle(): number {
let rads = this.rotation * (Math.PI / 180);
if (rads >= Math.PI) {
+ // Physics system guarantees rotation \in [0, 360)
rads -= Math.PI;
}
return rads;
diff --git a/engine/components/NetworkUpdateable.ts b/engine/components/NetworkUpdateable.ts
new file mode 100644
index 0000000..73ceeba
--- /dev/null
+++ b/engine/components/NetworkUpdateable.ts
@@ -0,0 +1,7 @@
+import { Component, ComponentNames } from ".";
+
+export class NetworkUpdateable extends Component {
+ constructor() {
+ super(ComponentNames.NetworkUpdateable);
+ }
+}
diff --git a/engine/components/index.ts b/engine/components/index.ts
index 67f1259..90f4965 100644
--- a/engine/components/index.ts
+++ b/engine/components/index.ts
@@ -12,4 +12,5 @@ export * from "./WallBounded";
export * from "./Gravity";
export * from "./Mass";
export * from "./Moment";
+export * from "./NetworkUpdateable";
export * from "./names";
diff --git a/engine/components/names.ts b/engine/components/names.ts
index e2ee3d3..02ee064 100644
--- a/engine/components/names.ts
+++ b/engine/components/names.ts
@@ -12,4 +12,5 @@ export namespace ComponentNames {
export const Forces = "Forces";
export const Mass = "Mass";
export const Moment = "Moment";
+ export const NetworkUpdateable = "NetworkUpdateable";
}