add client side physics

by god did this take a lot of debugging to get working
This commit is contained in:
Asraelite 2016-03-24 00:13:10 +00:00
parent 65f78ec3ac
commit 1412cabbb4
19 changed files with 697 additions and 71 deletions

View file

@ -5,7 +5,7 @@ function renderAsteroid(pallet, body) {
var vx = -game.world.getCenter().x;
var vy = -game.world.getCenter().y;
pallet.view(x + vx, y + vy, false, body.r);
pallet.view(x + vx, y + vy, false, pos.r);
var context = pallet.context;
var points = body.frame[0];

View file

@ -54,7 +54,7 @@ function Renderer() {
} else if (body.bodyType == 'asteroid') {
renderAsteroid(pallet, body);
} else {
pallet.rect('#338', body.x, body.y, 10, 10);
// Render structures, projectiles etc..
}
}

View file

@ -8,12 +8,12 @@ function renderShip(pallet, ship) {
var turr = game.assets.images.turrets['01'].small;
//pallet.view(ship.x, ship.y, false, ship.r);
var pos = ship.getPos();
var x = pos.x;
var y = pos.y;
var x = pos.x * SCALE;
var y = pos.y * SCALE;
var vx = -game.world.getCenter().x;
var vy = -game.world.getCenter().y;
pallet.view(x + vx, y + vy, false, ship.r);
pallet.view(x + vx, y + vy, false, pos.r);
var ts = ship.size / 2;
for (var i = 0; i < ship.mounts.length; i++) {
@ -27,4 +27,6 @@ function renderShip(pallet, ship) {
pallet.image(ship.move[0] ? thr8 : thr0, 0, 0, 0);
pallet.restore();
//pallet.text(ship.name, x + vx | 0, y + vy | 0, '#fff', 'FreePixel', 16, 'center', 'bottom');
}