add asteroids
This commit is contained in:
parent
0ceea5f4af
commit
0aa259b874
17 changed files with 246 additions and 37 deletions
22
public/js/starbugs/render/asteroids.js
Normal file
22
public/js/starbugs/render/asteroids.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
function renderAsteroid(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, body.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.strokeStyle = '#fff';
|
||||
context.stroke();
|
||||
|
||||
pallet.restore();
|
||||
}
|
|
@ -51,6 +51,8 @@ function Renderer() {
|
|||
|
||||
if (body.bodyType == 'ship') {
|
||||
renderShip(pallet, body);
|
||||
} else if (body.bodyType == 'asteroid') {
|
||||
renderAsteroid(pallet, body);
|
||||
} else {
|
||||
pallet.rect('#338', body.x, body.y, 10, 10);
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ function renderShip(pallet, ship) {
|
|||
var thr8 = game.assets.images.ships[ship.hull].thrust8;
|
||||
//pallet.view(ship.x, ship.y, false, ship.r);
|
||||
var pos = ship.getPos();
|
||||
var x = pos.x + 16;
|
||||
var y = pos.y + 16;
|
||||
var x = pos.x;
|
||||
var y = pos.y;
|
||||
var vx = -game.world.getCenter().x;
|
||||
var vy = -game.world.getCenter().y;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue