add start of gun support

This commit is contained in:
Asraelite 2016-03-22 23:46:55 +00:00
parent 444533ce85
commit 65f78ec3ac
19 changed files with 141 additions and 29 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 B

View file

@ -10,6 +10,11 @@ function loadAssets() {
thrust5: 'img/ships/01/thrust5.png',
thrust8: 'img/ships/01/thrust8.png'
}
},
turrets: {
'01': {
small: 'img/turrets/01/small.png'
}
}
}
}
@ -19,7 +24,6 @@ function loadAssets() {
// Magical recursive magic.
(function r(o, t) {
for (var i in o) {
console.log(i);
if (typeof o[i] == 'string') {
t[i] = new Image();
t[i].src = o[i];

View file

@ -5,6 +5,7 @@ function renderShip(pallet, ship) {
var thr0 = game.assets.images.ships[ship.hull].thrust0;
var thr5 = game.assets.images.ships[ship.hull].thrust5;
var thr8 = game.assets.images.ships[ship.hull].thrust8;
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;
@ -13,7 +14,15 @@ function renderShip(pallet, ship) {
var vy = -game.world.getCenter().y;
pallet.view(x + vx, y + vy, false, ship.r);
var ts = ship.size / 2;
for (var i = 0; i < ship.mounts.length; i++) {
if (ship.turrets[i]) {
pallet.image(turr, ship.mounts[i][0] - ts, ship.mounts[i][1] - ts, 0);
}
}
pallet.image(ship.team == 'a' ? teama : teamb, 0, 0, 0);
pallet.image(ship.move[0] ? thr8 : thr0, 0, 0, 0);
pallet.image(img, 0, 0, 0);
pallet.image(ship.move[0] ? thr8 : thr0, 0, 0, 0);

View file

@ -9,6 +9,14 @@ function Ship(data) {
this.rvel = data.delta[5];
this.hull = '01';
this.move = [];
this.mounts = data.mounts;
this.turrets = data.turrets;
this.frame = data.frame;
this.size = {
'small': 8,
'medium': 16,
'large': 24
}[data.size];
this.lastMove = [];
this.bodyType = 'ship';
this.com = {