Ignore:
Timestamp:
01/17/12 01:34:00 (12 years ago)
Author:
atzm
Message:
  • multi enemies support
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pycodeshooter/trunk/shooter/barrage.js

    r106 r108  
    2525 
    2626    this.aim = function(trooper, enemy) { 
     27        if (!trooper || !enemy) 
     28            return 0.5 * Math.PI; 
    2729        var dx = enemy.x - trooper.x; 
    2830        var dy = enemy.y - trooper.y; 
     
    3436        return this.aim(trooper, enemy) / Math.PI; 
    3537    }; 
    36     this.update = function(trooper, enemy) { 
     38    this.update = function(trooper, enemies) { 
    3739        return false; 
    3840    }; 
     
    4951 
    5052    that.state  = 0; 
    51     that.update = function(trooper, enemy) { 
     53    that.update = function(trooper, enemies) { 
    5254        if (++this.state < this.interval) 
    5355            return false; 
    5456 
    55         var dir = this.angle(trooper, enemy); 
     57        var dir = this.angle(trooper, enemies[0]); 
    5658 
    5759        trooper.addBullet(this.bullet, this.size, this.color, 
     
    9193 
    9294    that.state  = 0; 
    93     that.update = function(trooper, enemy) { 
     95    that.update = function(trooper, enemies) { 
    9496        if (++this.state < this.interval) 
    9597            return false; 
    9698 
    97         var angle = this.angle(trooper, enemy) - (this.delta * (this.way - 1) / 2); 
     99        var angle = this.angle(trooper, enemies[0]) - (this.delta * (this.way - 1) / 2); 
    98100 
    99101        for (var i = 0; i < this.way; i++) { 
     
    135137    that.curAngle = null; 
    136138 
    137     that.update = function(trooper, enemy) { 
     139    that.update = function(trooper, enemies) { 
    138140        if (++this.state < this.interval) 
    139141            return false; 
    140142 
    141143        if (this.curAngle == null) 
    142             this.curAngle = this.angle(trooper, enemy) - 
     144            this.curAngle = this.angle(trooper, enemies[0]) - 
    143145                this.delta * (this.way - 1) / 2; 
    144146 
     
    268270    }; 
    269271 
    270     this.update = function(trooper, enemy) { 
     272    this.update = function(trooper, enemies) { 
    271273        for (var i = 0; i < this.brrg.length; i++) { 
    272274            if (!this.flag[i]) 
    273                 this.flag[i] = this.brrg[i].update(trooper, enemy); 
     275                this.flag[i] = this.brrg[i].update(trooper, enemies); 
    274276        } 
    275277        for (var i = 0; i < this.flag.length; i++) { 
Note: See TracChangeset for help on using the changeset viewer.