Skip to content
Browse files

egg ammo

  • Loading branch information...
1 parent cd621b9 commit a9123433bef0a7c486948f8ae47e9dc02765888b @severest severest committed Nov 24, 2012
Showing with 14 additions and 5 deletions.
  1. +12 −4 components.js
  2. +1 −1 game.js
  3. +1 −0 index.html
View
16 components.js
@@ -20,13 +20,17 @@ Crafty.c("HurtForky" , {
}
});
Crafty.c("StraightBullets", {
- setSpeed: function(speedX, speedY) {
+
+ setSpeed: function(speedX, speedY, rot) {
this.bind('EnterFrame', function () {
this.y += speedY;
this.x += speedX;
+ this.rotation += rot;
if (this.y > STAGE_HEIGHT || this.y < (0-this.h) || this.x < (0-this.w) || this.x > STAGE_WIDTH)
this.destroy();
});
+
+ return this;
}
});
Crafty.c("LockingMissles", {
@@ -61,7 +65,9 @@ Crafty.c("LockingMissles", {
if (this.y > STAGE_HEIGHT || this.y < 0 || this.x < 0 || this.x > STAGE_WIDTH)
this.destroy();
+
});
+ return this;
}
});
@@ -110,10 +116,12 @@ Crafty.c("SimpleEnemy", {
},
fireWeapon: function() {
- Crafty.e("Bullet, 2D, DOM, Image, StraightBullets, HurtForky")
- .image("imgs/bullet.png")
+ Crafty.e("Bullet, 2D, DOM, eggbullet, SpriteAnimation, StraightBullets, HurtForky")
+ .animate("go", 0, 0, 4)
+ .animate("go", 20, -1)
.attr({ x: this.x, y: this.y, z: 4})
- .setSpeed(0,5);
+ .setSpeed(0,5,2)
+ .origin("center");
this.realDelay(this.fireWeapon, 1000);
}
});
View
2 game.js
@@ -16,7 +16,7 @@ window.onload = function () {
Crafty.sprite(20, 80, "imgs/bacon2.png", {firebacon:[0,0]});
Crafty.sprite(120, "imgs/burger_sheet.png", {burg:[0,0]});
Crafty.sprite(100,91, "imgs/egg_ss.png", {egg:[0,0]});
- Crafty.sprite(100,91, "imgs/eggbullet.png", {eggbullet:[0,0]});
+ Crafty.sprite(40,50, "imgs/eggbullet.png", {eggbullet:[0,0]});
Crafty.sprite(80,71, "imgs/onion_ss.png", {onion:[0,0]});
Crafty.sprite(100, "imgs/fireball.png", {fireball:[0,0]});
Crafty.sprite(39,36, "imgs/peppermint.png", {peppermint:[0,0]});
View
1 index.html
@@ -2,6 +2,7 @@
<head>
<script type="text/javascript" src="js/crafty-min.js"></script>
+ <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="game.js"></script>
<script type="text/javascript" src="components.js"></script>
<script type="text/javascript" src="js/realDelay.js"></script>

0 comments on commit a912343

Please sign in to comment.
Something went wrong with that request. Please try again.