From 5f446bafd2cc9526ea6cb2a4eec10b5c9a1122b9 Mon Sep 17 00:00:00 2001 From: Sean Everest Date: Sun, 11 Nov 2012 11:57:04 -0800 Subject: [PATCH] Revert "Revert "Revert "jojojojoj""" This reverts commit 89854200333924606e919555fb19b61af924a306. --- components.js | 21 +++++++++--------- game.js | 13 ++++++++++- index.html | 1 - js/realDelay.js | 57 ------------------------------------------------- 4 files changed, 22 insertions(+), 70 deletions(-) delete mode 100644 js/realDelay.js diff --git a/components.js b/components.js index db40dcda5e..7a33fadccf 100644 --- a/components.js +++ b/components.js @@ -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(); }); } @@ -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"); @@ -43,7 +43,6 @@ Crafty.c("SimpleEnemy", { this.destroy(); } }); - return this; }, fireWeapon: function() { @@ -51,8 +50,10 @@ Crafty.c("SimpleEnemy", { .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); } }); @@ -154,7 +155,5 @@ Crafty.c("OnJetpack", { this.x += this.speedX; this.y += this.speedY; }); - - return this; } }); \ No newline at end of file diff --git a/game.js b/game.js index 6d74c2e834..5a8aa23b15 100644 --- a/game.js +++ b/game.js @@ -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)); }); @@ -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" } diff --git a/index.html b/index.html index 30e56018d4..fab6630edd 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,6 @@ - My Crafty Game