made graphics more cartoony

This commit is contained in:
Asraelite 2016-03-26 14:23:02 +00:00
parent e53ff60ab7
commit 41a3a295c6
9 changed files with 17 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 486 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

BIN
public/img/main.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 355 B

After

Width:  |  Height:  |  Size: 422 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

View file

@ -15,9 +15,14 @@ Renderer.prototype.renderAsteroid = (pallet, body) => {
context.lineTo(points[i][0], points[i][1]); context.lineTo(points[i][0], points[i][1]);
} }
context.closePath(); context.closePath();
context.strokeStyle = '#fff'; context.clip();
context.fillStyle = body.debug ? `rgb(${body.debug}, 9, 9)` : '#090909'; context.fillStyle = body.debug ? `rgb(${body.debug}, 9, 9)` : '#090909';
context.fill(); context.fill();
context.lineWidth = 7;
context.strokeStyle = '#000';
context.stroke();
context.lineWidth = 3;
context.strokeStyle = '#fff';
context.stroke(); context.stroke();
pallet.restore(); pallet.restore();

View file

@ -39,7 +39,7 @@ class Renderer {
} }
pallet.clear(); pallet.clear();
pallet.fill('#000'); pallet.fill('#020202');
context.save(); context.save();
@ -49,16 +49,20 @@ class Renderer {
// Grid // Grid
var gridx = cx % 50; var gridx = cx % 50;
var gridy = cy % 50; var gridy = cy % 50;
pallet.opacity(0.05);
for (var x = gridx - cw / 2 - 50; x < cw + 50; x += 50) { for (var x = gridx - cw / 2 - 50; x < cw + 50; x += 50) {
for (var y = gridy - ch / 2 - 50; y < ch + 50; y += 50) { for (var y = gridy - ch / 2 - 50; y < ch + 50; y += 50) {
var wx = (-cx + x) / SCALE; var wx = (-cx + x) / SCALE;
var wy = (-cy + y) / SCALE; var wy = (-cy + y) / SCALE;
var b = game.world.bounds; var b = game.world.bounds;
if (wx > b.right || wx < b.left || wy > b.bottom || wy < b.top) if (wx > b.right || wx < b.left || wy > b.bottom || wy < b.top) {
pallet.outline('#141424', x, y, 51, 51, 1); pallet.opacity(0.2);
else pallet.outline('#0a0a0a', x, y, 51, 51, 1); pallet.outline('#8af', x, y, 51, 51, 1);
pallet.opacity(0.05);
} else pallet.outline('#fff', x, y, 51, 51, 1);
} }
} }
pallet.opacity(1);
for (var id in game.world.bodies) { for (var id in game.world.bodies) {
var body = game.world.bodies[id]; var body = game.world.bodies[id];

View file

@ -60,6 +60,7 @@ class Physics {
} }
removeBody(body) { removeBody(body) {
if (body)
this.toRemove.push(body.b2body); this.toRemove.push(body.b2body);
} }
@ -81,6 +82,7 @@ class Physics {
body.b2body.SetLinearVelocity(new b2Vec2(body.xvel, body.yvel)); body.b2body.SetLinearVelocity(new b2Vec2(body.xvel, body.yvel));
body.b2body.SetAngularVelocity(body.rvel); body.b2body.SetAngularVelocity(body.rvel);
} }
for (var i = 0; i < this.toRemove.length; i++) { for (var i = 0; i < this.toRemove.length; i++) {
this.world.DestroyBody(this.toRemove[i]); this.world.DestroyBody(this.toRemove[i]);
} }

View file

@ -38,15 +38,11 @@ class World {
if (data.type == 'structure') body = new Structure(data); if (data.type == 'structure') body = new Structure(data);
if (data.type == 'missile') body = new Missile(data); if (data.type == 'missile') body = new Missile(data);
//if(data.type == 'ship') console.log(body);
this.bodies[body.id] = body; this.bodies[body.id] = body;
//if(data.type == 'ship') console.log(this.bodies);
this.physics.createBody(body); this.physics.createBody(body);
}; };
remove(id) { remove(id) {
//console.log(id);
this.physics.removeBody(this.bodies[id]); this.physics.removeBody(this.bodies[id]);
delete this.bodies[id]; delete this.bodies[id];
}; };