Skip to content

Commit

Permalink
Revert "Revert "Revert "jojojojoj"""
Browse files Browse the repository at this point in the history
This reverts commit 8985420.
  • Loading branch information
severest committed Nov 11, 2012
1 parent 19f6cda commit 5f446ba
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 70 deletions.
21 changes: 10 additions & 11 deletions components.js
Expand Up @@ -14,11 +14,10 @@ Crafty.c("StraightBullets", {
});
},

setSpeed: function(speedX, speedY) {
setSpeed: function(speed) {
this.bind('EnterFrame', function () {
this.y += speedY;
this.x += speedX;
if (this.y > STAGE_HEIGHT || this.y < 0 || this.x < 0 || this.x > STAGE_WIDTH)
this.y += speed;
if (this.y > STAGE_HEIGHT)
this.destroy();
});
}
Expand All @@ -27,8 +26,9 @@ Crafty.c("StraightBullets", {
// ENEMIES
Crafty.c("SimpleEnemy", {
init: function () {
this.requires("RealDelay");
this.realDelay(this.fireWeapon, 1000);
this.timeout(function() {
this.fireWeapon();
}, 1000);
this.requires("Collision")
.onHit("Forky", function() {
console.log("ouch, bullet");
Expand All @@ -43,16 +43,17 @@ Crafty.c("SimpleEnemy", {
this.destroy();
}
});
return this;
},

fireWeapon: function() {
Crafty.e("Bullet, 2D, DOM, Image, StraightBullets")
.image("imgs/bullet.png")
.origin("center")
.attr({ x: this.x, y: this.y, z: 4})
.setSpeed(0,5);
this.realDelay(this.fireWeapon, 1000);
.setSpeed(5);
this.timeout(function() {
this.fireWeapon();
}, 1000);
}
});

Expand Down Expand Up @@ -154,7 +155,5 @@ Crafty.c("OnJetpack", {
this.x += this.speedX;
this.y += this.speedY;
});

return this;
}
});
13 changes: 12 additions & 1 deletion game.js
Expand Up @@ -60,7 +60,10 @@ window.onload = function () {
.configMovement(0.1,10);

Crafty.e("SimpleEnemyFactory, Delay")
.delay(spawnSimpleEnemy, Crafty.math.randomInt(200, 3000));
.delay(function () {
spawnSimpleEnemy();
this.delay();
}, Crafty.math.randomInt(200, 3000));


});
Expand All @@ -87,12 +90,20 @@ window.onload = function () {
}

function spawnSimpleEnemy() {
<<<<<<< HEAD
var e = Crafty.e("Enemy, 2D, DOM, burg, SpriteAnimation, SimpleEnemy, Delay")
.attr({ x: Crafty.math.randomInt(20, STAGE_WIDTH), y: -50, z: 2})
.animate("burger", [[0,0],[1,0],[2,0],[3,0],[4,0], [5,0], [6,0], [7,0], [8,0], [9,0], [10,0], [11,0], [12,0], [13,0], [14,0], [15,0], [16,0], [17,0], [18,0], [19,0], [20,0], [21,0], [22,0]] )
.animate("burger", 60, -1)
.setSpeed(1.5);
e.delay(spawnSimpleEnemy, Crafty.math.randomInt(200, 3000));
=======
Crafty.e("Enemy, 2D, DOM, Image, SimpleEnemy")
.image("imgs/enemy.png")
.attr({ x: Crafty.math.randomInt(20, STAGE_WIDTH), y: -50, z: 2})
.setSpeed(1.5);
//this.delay(arguments.callee, Crafty.math.randomInt(200, 3000));
>>>>>>> Revert "jojojojoj"
}


Expand Down
1 change: 0 additions & 1 deletion index.html
Expand Up @@ -4,7 +4,6 @@

<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>

<title>My Crafty Game</title>
<style>
Expand Down
57 changes: 0 additions & 57 deletions js/realDelay.js

This file was deleted.

0 comments on commit 5f446ba

Please sign in to comment.