Skip to content

Commit

Permalink
Tweaks to creep rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
ricochet1k committed Apr 5, 2017
1 parent 858723d commit 783c137
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/scripts/objects/creep.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class Creep extends GameObject {
if (!firstCreep) firstCreep = this;

let parts = this.parts = {};
for (let i = 0; i < obj.body.length; i++) {
for (let i in obj.body) {
let b = obj.body[i];

parts[b.type] = (parts[b.type] || 0) + 1;
Expand Down
10 changes: 6 additions & 4 deletions src/scripts/skins/original/creep.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export class CreepSkin {
bodyCount[part.type] = (bodyCount[part.type]||0) + 1;
}

let m = S(5); // middle
let pw = S(2); // part width/thickness
let pr = S(5); // part outer radius
const m = S(5); // middle
const pw = S(2); // part width/thickness
const pr = S(5); // part outer radius

const tau = Math.PI * 2;
const pi = Math.PI;
Expand All @@ -94,7 +94,9 @@ export class CreepSkin {

g.lineStyle(0, 0, 0);
g.beginFill(0xffff00);
g.drawCircle(S(5), S(5), S(2.5) * obj.energy / obj.energyCapacity);
let e = S(2.5) * Math.sqrt(obj.energy / obj.energyCapacity);
if (obj.energy > 0) e = Math.max(1, e);
g.drawCircle(m, m, e);
g.endFill();

tweenRotation(TWEEN_DURATION/2, g, this.creep.lastObj, obj);
Expand Down

0 comments on commit 783c137

Please sign in to comment.