bard-legends-framework 0.1.31 → 0.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/physics/entitity-types/immovable-physics-entity.js +1 -1
- package/dist/physics/entitity-types/movable-entity.d.ts +1 -1
- package/dist/physics/entitity-types/movable-entity.js +2 -2
- package/dist/physics/entitity-types/movable-physics-entity.d.ts +2 -2
- package/dist/physics/entitity-types/movable-physics-entity.js +10 -10
- package/dist/physics/interfaces.d.ts +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,6 @@ export declare abstract class MovableEntity extends Entity {
|
|
|
5
5
|
readonly position: Variable<Vec2>;
|
|
6
6
|
readonly rotation: Variable<number>;
|
|
7
7
|
readonly velocity: Variable<Vec2>;
|
|
8
|
-
readonly
|
|
8
|
+
readonly rotationalSpeed: Variable<number>;
|
|
9
9
|
update(time: number, delta: number): void;
|
|
10
10
|
}
|
|
@@ -9,14 +9,14 @@ class MovableEntity extends game_entities_1.Entity {
|
|
|
9
9
|
this.position = new actions_lib_1.Variable().set({ x: 0, y: 0 });
|
|
10
10
|
this.rotation = new actions_lib_1.Variable().set(0);
|
|
11
11
|
this.velocity = new actions_lib_1.Variable().set({ x: 0, y: 0 });
|
|
12
|
-
this.
|
|
12
|
+
this.rotationalSpeed = new actions_lib_1.Variable().set(0);
|
|
13
13
|
}
|
|
14
14
|
update(time, delta) {
|
|
15
15
|
this.position.value = {
|
|
16
16
|
x: this.position.value.x + this.velocity.value.x * delta,
|
|
17
17
|
y: this.position.value.y + this.velocity.value.y * delta
|
|
18
18
|
};
|
|
19
|
-
this.rotation.value = this.rotation.value + this.
|
|
19
|
+
this.rotation.value = this.rotation.value + this.rotationalSpeed.value * delta;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
exports.MovableEntity = MovableEntity;
|
|
@@ -7,12 +7,12 @@ export declare abstract class MovablePhysicsEntity extends PhysicsEntity {
|
|
|
7
7
|
readonly position: Variable<Vec2>;
|
|
8
8
|
readonly rotation: Variable<number>;
|
|
9
9
|
readonly velocity: Variable<Vec2>;
|
|
10
|
-
readonly
|
|
10
|
+
readonly rotationalSpeed: Variable<number>;
|
|
11
11
|
readonly onCollision: Action<CollisionReport[]>;
|
|
12
12
|
private ignorePositionUpdate;
|
|
13
13
|
private ignoreRotationUpdate;
|
|
14
14
|
private ignoreVelocityUpdate;
|
|
15
|
-
private
|
|
15
|
+
private ignoreRotationalSpeedUpdate;
|
|
16
16
|
constructor(physicsWorld: PhysicsWorld, physicsEntityDefinition: PhysicsEntityDefinition);
|
|
17
17
|
convertToDTO(): PhysicsBodyDTO;
|
|
18
18
|
private step;
|
|
@@ -10,12 +10,12 @@ class MovablePhysicsEntity extends physics_entity_1.PhysicsEntity {
|
|
|
10
10
|
this.position = new actions_lib_1.Variable().set({ x: 0, y: 0 });
|
|
11
11
|
this.rotation = new actions_lib_1.Variable().set(0);
|
|
12
12
|
this.velocity = new actions_lib_1.Variable().set({ x: 0, y: 0 });
|
|
13
|
-
this.
|
|
13
|
+
this.rotationalSpeed = new actions_lib_1.Variable().set(0);
|
|
14
14
|
this.onCollision = new actions_lib_1.Action();
|
|
15
15
|
this.ignorePositionUpdate = false;
|
|
16
16
|
this.ignoreRotationUpdate = false;
|
|
17
17
|
this.ignoreVelocityUpdate = false;
|
|
18
|
-
this.
|
|
18
|
+
this.ignoreRotationalSpeedUpdate = false;
|
|
19
19
|
this.phsicsToLocalSync();
|
|
20
20
|
this.localToPhsicsSync();
|
|
21
21
|
this.physicsWorld.onPhysicsStep.subscribe(({ time, delta }) => this.step(time, delta)).attach(this);
|
|
@@ -27,21 +27,21 @@ class MovablePhysicsEntity extends physics_entity_1.PhysicsEntity {
|
|
|
27
27
|
position: this.position.value,
|
|
28
28
|
rotation: this.rotation.value,
|
|
29
29
|
velocity: this.velocity.value,
|
|
30
|
-
|
|
30
|
+
rotationalSpeed: this.rotationalSpeed.value
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
step(time, delta) {
|
|
34
34
|
this.ignorePositionUpdate = true;
|
|
35
35
|
this.ignoreRotationUpdate = true;
|
|
36
36
|
this.ignoreVelocityUpdate = true;
|
|
37
|
-
this.
|
|
37
|
+
this.ignoreRotationalSpeedUpdate = true;
|
|
38
38
|
this.phsicsToLocalSync();
|
|
39
39
|
}
|
|
40
40
|
phsicsToLocalSync() {
|
|
41
41
|
this.position.value = p2js_helper_1.P2JSHelper.arrayToVec2(this.body.position);
|
|
42
42
|
this.rotation.value = this.body.angle;
|
|
43
43
|
this.velocity.value = p2js_helper_1.P2JSHelper.arrayToVec2(this.body.velocity);
|
|
44
|
-
this.
|
|
44
|
+
this.rotationalSpeed.value = this.body.angularVelocity;
|
|
45
45
|
}
|
|
46
46
|
localToPhsicsSync() {
|
|
47
47
|
this.position
|
|
@@ -74,13 +74,13 @@ class MovablePhysicsEntity extends physics_entity_1.PhysicsEntity {
|
|
|
74
74
|
}
|
|
75
75
|
})
|
|
76
76
|
.attach(this);
|
|
77
|
-
this.
|
|
78
|
-
.subscribe(
|
|
79
|
-
if (this.
|
|
80
|
-
this.
|
|
77
|
+
this.rotationalSpeed
|
|
78
|
+
.subscribe(rotationalSpeed => {
|
|
79
|
+
if (this.ignoreRotationalSpeedUpdate) {
|
|
80
|
+
this.ignoreRotationalSpeedUpdate = false;
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
|
-
let torque = (
|
|
83
|
+
let torque = (rotationalSpeed - this.body.angularVelocity) / this.body.invInertia;
|
|
84
84
|
this.body.angularForce = torque;
|
|
85
85
|
}
|
|
86
86
|
})
|
|
@@ -35,7 +35,7 @@ export interface PhysicsBodyDTO {
|
|
|
35
35
|
readonly position: Vec2;
|
|
36
36
|
readonly rotation: number;
|
|
37
37
|
readonly velocity: Vec2;
|
|
38
|
-
readonly
|
|
38
|
+
readonly rotationalSpeed: number;
|
|
39
39
|
}
|
|
40
40
|
export interface CollisionDetails {
|
|
41
41
|
readonly body: PhysicsBodyDTO;
|