Skip to content

Commit

Permalink
can hold down space to shoot
Browse files Browse the repository at this point in the history
  • Loading branch information
severest committed Nov 20, 2012
1 parent d1e9dc4 commit ba41a2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions components.js
Expand Up @@ -165,14 +165,19 @@ Crafty.c("RandomMover", {
Crafty.c("ForkyBase", { Crafty.c("ForkyBase", {
bulletSpeed: 3, bulletSpeed: 3,
init: function () { init: function () {
this.canFire = true;
this.fireTimeout = 200;

this.requires("2D").requires("DOM").requires("forkysprite").requires("SpriteAnimation").requires("OnJetpack").requires("Keyboard").requires("RealDelay") this.requires("2D").requires("DOM").requires("forkysprite").requires("SpriteAnimation").requires("OnJetpack").requires("Keyboard").requires("RealDelay")
.attr({ x: 580, y: 100, z: 2}) .attr({ x: 580, y: 100, z: 2})
.animate("idle", 0, 0, 4) .animate("idle", 0, 0, 4)
.animate("lean", 4, 0, 7) .animate("lean", 4, 0, 7)
.animate("idle", 20, -1) .animate("idle", 20, -1)
.configMovement(0.1,10) .configMovement(0.1,10)
.bind('KeyDown', function () { .bind('EnterFrame', function () {
if (this.isDown("SPACE")) { if (this.isDown("SPACE") && this.canFire) {
this.canFire = false;
this.realDelay(function(){this.canFire = true;},this.fireTimeout); // fire weapon timeout
this.fireBaseWeapon(); this.fireBaseWeapon();
} }
}); });
Expand Down
4 changes: 2 additions & 2 deletions game.js
Expand Up @@ -136,13 +136,13 @@ function spawnSimpleEnemy() {
Crafty.e("Enemy, 2D, DOM, onion, SpriteAnimation, EnemyBase, SimpleEnemy") Crafty.e("Enemy, 2D, DOM, onion, SpriteAnimation, EnemyBase, SimpleEnemy")
.attr({ x: Crafty.math.randomInt(20, STAGE_WIDTH), y: -50, z: 2}) .attr({ x: Crafty.math.randomInt(20, STAGE_WIDTH), y: -50, z: 2})
.animate("idle", 0, 0, 4) .animate("idle", 0, 0, 4)
.animate("idle", 60, -1) .animate("idle", 30, -1)
.setSpeed(1.5); .setSpeed(1.5);


Crafty.e("Enemy, 2D, DOM, egg, SpriteAnimation, EnemyBase, SimpleEnemy") Crafty.e("Enemy, 2D, DOM, egg, SpriteAnimation, EnemyBase, SimpleEnemy")
.attr({ x: Crafty.math.randomInt(20, STAGE_WIDTH), y: -50, z: 2}) .attr({ x: Crafty.math.randomInt(20, STAGE_WIDTH), y: -50, z: 2})
.animate("idle", 0, 0, 3) .animate("idle", 0, 0, 3)
.animate("idle", 60, -1) .animate("idle", 20, -1)
.setSpeed(1.5); .setSpeed(1.5);




Expand Down

0 comments on commit ba41a2f

Please sign in to comment.