add basic ship movement and tracking
This commit is contained in:
parent
fcfe1e8790
commit
05ad81ed8d
10 changed files with 65 additions and 27 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
const uuid = require('uuid');
|
||||
|
||||
const b2Vec2 = require('box2d-html5').b2Vec2;
|
||||
|
||||
class Body {
|
||||
constructor(world) {
|
||||
this.x = 0;
|
||||
|
@ -18,6 +20,15 @@ class Body {
|
|||
this.world.applyDelta(this.id, this.pack());
|
||||
}
|
||||
|
||||
applyForce(x, y, center) {
|
||||
let b = this.b2body;
|
||||
b.ApplyForce(new b2Vec2(x, y), b.GetWorldCenter());
|
||||
}
|
||||
|
||||
applyTorque(f) {
|
||||
this.b2body.ApplyTorque(f);
|
||||
}
|
||||
|
||||
pack() {
|
||||
let pos = this.b2body.GetPosition();
|
||||
let rot = this.b2body.GetAngleRadians();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue