add basic updating to client on physics
This commit is contained in:
parent
95e0f6b710
commit
1027d980c1
15 changed files with 160 additions and 13 deletions
|
@ -0,0 +1,5 @@
|
|||
function Ship(id) {
|
||||
this.id = id;
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
}
|
20
public/js/starbugs/world/world.js
Normal file
20
public/js/starbugs/world/world.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
function World() {
|
||||
this.bodies = {};
|
||||
this.playerShip = false;
|
||||
|
||||
this.update = function(data) {
|
||||
for (var id in data) {
|
||||
if (!this.bodies[id]) {
|
||||
this.bodies[id] = new Ship(id);
|
||||
this.playerShip = this.bodies[id];
|
||||
}
|
||||
|
||||
var body = this.bodies[id];
|
||||
body.x = data[id][0];
|
||||
body.y = data[id][1];
|
||||
body.r = data[id][2];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue