add basic missiles
This commit is contained in:
parent
21a30ad212
commit
ac089f3e8e
19 changed files with 215 additions and 85 deletions
25
public/js/starbugs/render/body.js
Normal file
25
public/js/starbugs/render/body.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
Renderer.prototype.renderBody = (pallet, body) => {
|
||||
var pos = body.getPos();
|
||||
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, pos.r);
|
||||
|
||||
var context = pallet.context;
|
||||
var points = body.frame[0];
|
||||
context.beginPath();
|
||||
context.moveTo(points[0][0], points[0][1]);
|
||||
for (var i = 1; i < points.length; i++) {
|
||||
context.lineTo(points[i][0], points[i][1]);
|
||||
}
|
||||
context.closePath();
|
||||
context.lineWidth = 0.5;
|
||||
context.strokeStyle = '#fff';
|
||||
context.fillStyle = '#200';
|
||||
context.fill();
|
||||
context.stroke();
|
||||
|
||||
pallet.restore();
|
||||
};
|
|
@ -66,6 +66,7 @@ class Renderer {
|
|||
} else if (body.bodyType == 'asteroid') {
|
||||
this.renderAsteroid(pallet, body);
|
||||
} else {
|
||||
this.renderBody(pallet, body);
|
||||
// Render structures, projectiles etc..
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue