Permalink
Browse files

give the user a penalty for not hitting the target

  • Loading branch information...
1 parent faef7e0 commit 886158da62389484c2e7edee9a56a6cbef348cde @frewsxcv committed Feb 20, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 twits.js
View
6 twits.js
@@ -183,6 +183,7 @@ function play(context, width, height, images) {
var firing = setInterval(function() {
var newY = shot.y - 15;
if (newY < 0) {
+ misfire();
shot.exit();
clearInterval(firing);
} else if (alien.collidesWith(shot.x, newY, shot.width(), shot.height())) {
@@ -200,6 +201,11 @@ function play(context, width, height, images) {
}
}, 30);
}
+
+ function misfire() {
+ spaceShip.score();
+ document.getElementById("score").innerHTML -= 50;
@dherman
dherman Feb 20, 2012

I can't believe I'm getting pull requests for this. :)

That said, this will get spaceShip.points and the contents of the "score" div out of sync.

+ }
function score() {
spaceShip.score();

0 comments on commit 886158d

Please sign in to comment.