Ignore:
Timestamp:
01/18/12 00:01:24 (12 years ago)
Author:
atzm
Message:

imaging support

File:
1 edited

Legend:

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

    r108 r109  
    7171}; 
    7272 
    73 var Trooper = function(name, actList, size, hitSize, color, hitColor, 
     73var Trooper = function(name, actList, image, size, hitSize, color, hitColor, 
    7474                       x, y, w, h, life, speed, numBombs, bombColors, barrages) { 
    7575 
     
    7878    this.name       = name; 
    7979    this.actList    = actList; 
     80    this.image      = image; 
    8081    this.size       = size; 
    8182    this.hitSize    = hitSize; 
     
    185186 
    186187        // draw trooper 
    187         ctx.beginPath(); 
    188         ctx.fillStyle = this.color; 
    189         ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2.0, true); 
    190         ctx.fill(); 
    191         ctx.closePath(); 
    192  
     188        if (this.image) { 
     189            var w = this.image.width * (this.size / this.image.height); 
     190            var h = this.size; 
     191            var x = this.x - (w / 2); 
     192            var y = this.y - (h / 2); 
     193            ctx.drawImage(this.image, x, y, w, h); 
     194        } 
     195        else { 
     196            ctx.beginPath(); 
     197            ctx.fillStyle = this.color; 
     198            ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2.0, true); 
     199            ctx.fill(); 
     200            ctx.closePath(); 
     201        } 
     202 
     203        // draw hit area 
    193204        if (this.color != this.hitColor || this.size != this.hitSize) { 
    194205            ctx.beginPath(); 
Note: See TracChangeset for help on using the changeset viewer.