Permalink
Browse files

Merge branch 'master' of github.com:stugoo/unicorn-super-blaster

  • Loading branch information...
2 parents dfad255 + 3130dc9 commit 1885532e1130a0ff96191d708441e0548d24b83d @adamcbrewer adamcbrewer committed Nov 10, 2012
Showing with 19 additions and 0 deletions.
  1. +19 −0 js/game.js
View
@@ -149,6 +149,17 @@
.animate('fly', 5, -1)
// set up fourway controller
.fourway(5)
+
+ .collision(new Crafty.polygon(
+ [10, 40],
+ [10, 80],
+ [180, 80],
+ [180, 40]
+ ))
+
+
+
+
// also react to the SPACE key being pressed
.requires('Keyboard')
.bind('KeyDown', function(e) {
@@ -158,11 +169,19 @@
}
});
+ this.onHit('Target', this.badGuyCollision);
+
// bind our movement handler to keep us within the Viewport
this.bind('Moved', function(oldPosition) {
this.checkOutOfBounds(oldPosition);
});
},
+ badGuyCollision: function() {
+ // replace the ship with an explosion!
+ Crafty.e("Explosion").attr({x:this.x, y:this.y});
+ this.destroy();
+
+ },
});
// A component to display the player's score

0 comments on commit 1885532

Please sign in to comment.