Skip to content
This repository
Browse code

damages refactored

  • Loading branch information...
commit f3e91fffdc61e6d00c9077414c3bf7e0f69d4767 1 parent 11629f7
Cyrille Bogaert authored November 20, 2012
6  game/components/characters/octocat.js
@@ -24,9 +24,9 @@ define([
24 24
             this.walk();
25 25
 
26 26
             this.onHit("Bullet", function(others) {
27  
-                others[0].obj.destroy();
28  
-                
29  
-                var damages = Math.round(Crafty.math.randomNumber(30,70));
  27
+                var bullet = others[0].obj;
  28
+                var damages = bullet.damages;
  29
+                bullet.destroy();
30 30
                 
31 31
                 this.takeDamages(damages);
32 32
                 this.git({x: 35, y: 45});
3  game/components/skills/attack.js
@@ -9,7 +9,8 @@ define([
9 9
             
10 10
             this.collision(new Crafty.polygon([8,14],[67,14],[67,5],[91,5],[91,24],[67,24],[67,20],[8,20]));
11 11
             
12  
-            this.attack = function(from, to) {
  12
+            this.cast = function(from, to, damages) {
  13
+                this.damages = Math.round(Crafty.math.randomNumber(damages.min, damages.max));
13 14
                 this.fire(from, to, this.speed);
14 15
             };
15 16
             
5  game/skills.js
@@ -17,10 +17,11 @@ define([
17 17
         cooldown: 0.7,
18 18
         action: function() {
19 19
             var player = PlayerEntity.get();
20  
-            Crafty.e("Attack").attack({
  20
+            var damages = { min: 30, max: 70 };
  21
+            Crafty.e("Attack").cast({
21 22
                 x: player.x+40,
22 23
                 y: player.y+25
23  
-            }, mousePosition());
  24
+            }, mousePosition(), damages);
24 25
         },
25 26
         backgroundPosition: "-424px 0"
26 27
     }, {

0 notes on commit f3e91ff

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