summaryrefslogtreecommitdiff
path: root/engine/components
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-26 17:55:27 -0600
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-26 17:55:27 -0600
commit6ce6946a4401d2ee6fa5cb747fab7d4c658a63c8 (patch)
treee60767dc5295edf379cf421e20171dc418e548b7 /engine/components
parent594921352c8d82fe5f1a6201a4d5f9fbd9b719fc (diff)
downloadjumpstorm-6ce6946a4401d2ee6fa5cb747fab7d4c658a63c8.tar.gz
jumpstorm-6ce6946a4401d2ee6fa5cb747fab7d4c658a63c8.zip
add entity updates over network!
Diffstat (limited to 'engine/components')
-rw-r--r--engine/components/BoundingBox.ts4
-rw-r--r--engine/components/Control.ts2
-rw-r--r--engine/components/NetworkUpdateable.ts8
3 files changed, 6 insertions, 8 deletions
diff --git a/engine/components/BoundingBox.ts b/engine/components/BoundingBox.ts
index dbe083e..921feb9 100644
--- a/engine/components/BoundingBox.ts
+++ b/engine/components/BoundingBox.ts
@@ -15,7 +15,6 @@ export class BoundingBox extends Component {
this.rotation = rotation ?? 0;
}
- // https://en.wikipedia.org/wiki/Hyperplane_separation_theorem
public isCollidingWith(box: BoundingBox): boolean {
if (this.rotation == 0 && box.rotation == 0) {
const thisTopLeft = this.getTopLeft();
@@ -36,6 +35,7 @@ export class BoundingBox extends Component {
return true;
}
+ // https://en.wikipedia.org/wiki/Hyperplane_separation_theorem
const boxes = [this.getVertices(), box.getVertices()];
for (const poly of boxes) {
for (let i = 0; i < poly.length; i++) {
@@ -89,6 +89,8 @@ export class BoundingBox extends Component {
let rads = this.getRotationInPiOfUnitCircle();
const { width, height } = this.dimension;
+ if (rads == 0) return this.dimension;
+
if (rads <= Math.PI / 2) {
return {
width: Math.abs(height * Math.sin(rads) + width * Math.cos(rads)),
diff --git a/engine/components/Control.ts b/engine/components/Control.ts
index beec82c..d3987d7 100644
--- a/engine/components/Control.ts
+++ b/engine/components/Control.ts
@@ -3,6 +3,7 @@ import { Component, ComponentNames, Velocity } from '.';
export class Control extends Component {
public controlVelocityComponent: Velocity;
public controllableBy: string;
+ public isControllable: boolean; // computed each update in the input system
constructor(
controllableBy: string,
@@ -12,5 +13,6 @@ export class Control extends Component {
this.controllableBy = controllableBy;
this.controlVelocityComponent = controlVelocityComponent;
+ this.isControllable = false;
}
}
diff --git a/engine/components/NetworkUpdateable.ts b/engine/components/NetworkUpdateable.ts
index 7fb6d18..014270c 100644
--- a/engine/components/NetworkUpdateable.ts
+++ b/engine/components/NetworkUpdateable.ts
@@ -1,13 +1,7 @@
import { Component, ComponentNames } from '.';
export class NetworkUpdateable extends Component {
- public isPublish: boolean;
- public isSubscribe: boolean;
-
- constructor(isPublish: boolean, isSubscribe: boolean) {
+ constructor() {
super(ComponentNames.NetworkUpdateable);
-
- this.isPublish = isPublish;
- this.isSubscribe = isSubscribe;
}
}