Skip to content

Instantly share code, notes, and snippets.

@FlyingJester
Created April 1, 2013 20:50
Show Gist options
  • Save FlyingJester/5287658 to your computer and use it in GitHub Desktop.
Save FlyingJester/5287658 to your computer and use it in GitHub Desktop.
function BodyPart.draw(spritex, spritey){
//this.color should be updated to an appropriate color whenever the bodypart takes damage.
//alternatively, if could be calculated at the start of this function.
integer number_of_nodes = this.nodes.length;
integer i = 0;
//this line handles the wraparound from the last to the first node.
line(this.nodes[0].x+spritex, this.nodes[0].y+spritey, nodes[number_of_nodes-1].xspritex, this.nodes[number_of_nodes-1].y+spritey, this.color);
while(i<(number_of_nodes-1)){
line(this.nodes[i].xspritex, this.nodes[i].y+spritey, this.nodes[i+1].xspritex, this.nodes[i+1].y+spritey, this.color);
i++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment