Skip to content
This repository has been archived by the owner on Nov 13, 2020. It is now read-only.

Commit

Permalink
Re-factored the heart drawing code
Browse files Browse the repository at this point in the history
Re-factored the heart drawing code to cache the jQuery object.
  • Loading branch information
Derek Smith committed Aug 20, 2012
1 parent 0f0e0d3 commit 6584a56
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions assets/scripts/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ window.app = {

setTimeout(function() {
app.player.hearts = 5;
app.graphics.drawHearts();
app.graphics.hearts.draw();
}, 200);
},

Expand All @@ -590,7 +590,7 @@ window.app = {
app.player.kill(killMessage);
return;
}
app.graphics.drawHearts();
app.graphics.hearts.draw();
}
},

Expand Down Expand Up @@ -990,10 +990,14 @@ window.app = {
return index;
},

drawHearts: function() {
$('#hearts .holder').empty();
for (var i = 0; i < app.player.hearts; i++) {
$('#hearts .holder').append('<div class="heart"></div>');
hearts: {
$holder = $('#hearts .holder'),

draw: function() {
app.graphics.hearts.$holder.empty();
for (var i = 0; i < app.player.hearts; i++) {
app.graphics.hearts.$holder.append('<div class="heart"></div>');
}
}
}
},
Expand Down

0 comments on commit 6584a56

Please sign in to comment.