add grappling hook sprite
This commit is contained in:
parent
02245ca5a9
commit
e9d1596c2f
12 changed files with 34 additions and 6 deletions
BIN
public/static/img/projectiles/02.png
Normal file
BIN
public/static/img/projectiles/02.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 266 B |
BIN
public/static/img/turrets/02/launched.png
Normal file
BIN
public/static/img/turrets/02/launched.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 210 B |
BIN
public/static/img/turrets/02/normal.png
Normal file
BIN
public/static/img/turrets/02/normal.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 293 B |
|
@ -16,6 +16,9 @@ Game.prototype.loadAssets = _ => {
|
||||||
small: 'img/turrets/01/normal.png'
|
small: 'img/turrets/01/normal.png'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
projectiles: {
|
||||||
|
'02': 'img/projectiles/02.png'
|
||||||
|
},
|
||||||
backgrounds: {
|
backgrounds: {
|
||||||
'01': 'img/space.jpg'
|
'01': 'img/space.jpg'
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,9 @@ class GUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
set visible(visible) {
|
set visible(visible) {
|
||||||
this.guiElement.style.display = visible ? 'block' : 'hidden';
|
if (visible)
|
||||||
|
this.guiElement.classList.remove('hidden');
|
||||||
|
else
|
||||||
|
this.guiElement.classList.add('hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,9 +62,9 @@ class Game {
|
||||||
this._state = state;
|
this._state = state;
|
||||||
|
|
||||||
if (state != 'connected') {
|
if (state != 'connected') {
|
||||||
this.gui.visible = true;
|
|
||||||
} else {
|
|
||||||
this.gui.visible = false;
|
this.gui.visible = false;
|
||||||
|
} else {
|
||||||
|
this.gui.visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ class BodyRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
render(body) {
|
render(body) {
|
||||||
let pos = body.getPos();
|
let pos = body.pos;
|
||||||
let x = pos.x * SCALE;
|
let x = pos.x * SCALE;
|
||||||
let y = pos.y * SCALE;
|
let y = pos.y * SCALE;
|
||||||
let vx = -game.world.center.x;
|
let vx = -game.world.center.x;
|
||||||
|
@ -28,6 +28,8 @@ class BodyRenderer {
|
||||||
this.renderShip(body);
|
this.renderShip(body);
|
||||||
} else if (body.bodyType == 'asteroid') {
|
} else if (body.bodyType == 'asteroid') {
|
||||||
this.renderAsteroid(body);
|
this.renderAsteroid(body);
|
||||||
|
} else if (body.bodyClass == 'projectile') {
|
||||||
|
this.renderProjectile(body);
|
||||||
} else {
|
} else {
|
||||||
this.renderBody(body);
|
this.renderBody(body);
|
||||||
}
|
}
|
||||||
|
@ -110,4 +112,16 @@ class BodyRenderer {
|
||||||
this.pallet.opacity(0.3);
|
this.pallet.opacity(0.3);
|
||||||
this.pallet.text(ship.name, x, y, '#fff', 'FreePixel', 16, 'center', 'bottom');
|
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();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,6 +37,10 @@ class Renderer {
|
||||||
this.pallet.fill('#020202');
|
this.pallet.fill('#020202');
|
||||||
|
|
||||||
this.context.save();
|
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);
|
this.pallet.view(cw / 2, ch / 2, 1, 0);
|
||||||
|
|
||||||
|
@ -44,7 +48,7 @@ class Renderer {
|
||||||
let img = game.assets.images.backgrounds['01'];
|
let img = game.assets.images.backgrounds['01'];
|
||||||
let bgx = -img.width / 2 - center.x / 20;
|
let bgx = -img.width / 2 - center.x / 20;
|
||||||
let bgy = -img.height / 2 - center.y / 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.pallet.opacity(1);
|
||||||
|
|
||||||
this.renderGrid();
|
this.renderGrid();
|
||||||
|
|
|
@ -10,6 +10,8 @@ class Body {
|
||||||
this.fixtures = data.fixtures;
|
this.fixtures = data.fixtures;
|
||||||
this.b2body = false;
|
this.b2body = false;
|
||||||
this.updated = 0;
|
this.updated = 0;
|
||||||
|
this.bodyClass = data.class;
|
||||||
|
this.bodyType = data.type;
|
||||||
|
|
||||||
this.update(data.delta.slice(1));
|
this.update(data.delta.slice(1));
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ class Ship extends Body {
|
||||||
'large': 24
|
'large': 24
|
||||||
}[data.size];
|
}[data.size];
|
||||||
this.lastMove = [];
|
this.lastMove = [];
|
||||||
this.bodyType = 'ship';
|
|
||||||
this.activeFixture = 0;
|
this.activeFixture = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ body
|
||||||
|
|
||||||
#gui
|
#gui
|
||||||
color #fff
|
color #fff
|
||||||
|
&.hidden *
|
||||||
|
display: none
|
||||||
.container
|
.container
|
||||||
position fixed
|
position fixed
|
||||||
#chat
|
#chat
|
||||||
|
|
|
@ -116,6 +116,7 @@ class Body {
|
||||||
packFull() {
|
packFull() {
|
||||||
let packet = {
|
let packet = {
|
||||||
type: this.type,
|
type: this.type,
|
||||||
|
class: this.class,
|
||||||
id: this.id,
|
id: this.id,
|
||||||
frame: this.frame,
|
frame: this.frame,
|
||||||
fixtures: this.mounts.map(m => m.packFull()),
|
fixtures: this.mounts.map(m => m.packFull()),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue