add grappling hook sprite

This commit is contained in:
Asraelite 2016-03-30 00:53:23 +01:00
parent 02245ca5a9
commit e9d1596c2f
12 changed files with 34 additions and 6 deletions

View file

@ -6,7 +6,7 @@ class BodyRenderer {
}
render(body) {
let pos = body.getPos();
let pos = body.pos;
let x = pos.x * SCALE;
let y = pos.y * SCALE;
let vx = -game.world.center.x;
@ -28,6 +28,8 @@ class BodyRenderer {
this.renderShip(body);
} else if (body.bodyType == 'asteroid') {
this.renderAsteroid(body);
} else if (body.bodyClass == 'projectile') {
this.renderProjectile(body);
} else {
this.renderBody(body);
}
@ -110,4 +112,16 @@ class BodyRenderer {
this.pallet.opacity(0.3);
this.pallet.text(ship.name, x, y, '#fff', 'FreePixel', 16, 'center', 'bottom');
}
renderProjectile(body) {
if (body.bodyType != 'grapple') {
this.renderBody(body);
return;
}
let img = game.assets.images.projectiles['02'];
let pos = body.pos;
this.pallet.image(img, -32, -32, 0);
this.pallet.restore();
}
};

View file

@ -37,6 +37,10 @@ class Renderer {
this.pallet.fill('#020202');
this.context.save();
this.context.beginPath();
this.context.rect(0, 0, cw, ch);
this.context.clip();
this.pallet.view(cw / 2, ch / 2, 1, 0);
@ -44,7 +48,7 @@ class Renderer {
let img = game.assets.images.backgrounds['01'];
let bgx = -img.width / 2 - center.x / 20;
let bgy = -img.height / 2 - center.y / 20;
this.pallet.image(img, bgx, bgy);
this.pallet.image(img, bgx, bgy, 0, img.width * 1.5, img.height * 1.5);
this.pallet.opacity(1);
this.renderGrid();