home *** CD-ROM | disk | FTP | other *** search
/ Champak 106 / Vol 106.iso / games / insuranc.swf / scripts / __Packages / Puddle.as < prev    next >
Encoding:
Text File  |  2010-04-12  |  1.1 KB  |  51 lines

  1. class Puddle
  2. {
  3.    var pos;
  4.    var type;
  5.    var mcPuddle;
  6.    var delay;
  7.    function Puddle(posNew, typeNew, mcCanvas)
  8.    {
  9.       this.pos = posNew.clone();
  10.       this.type = typeNew;
  11.       var _loc2_ = undefined;
  12.       if(this.type == 0)
  13.       {
  14.          _loc2_ = "oil";
  15.       }
  16.       else if(this.type == 1)
  17.       {
  18.          _loc2_ = "water";
  19.       }
  20.       this.mcPuddle = mcCanvas.attachMovie(_loc2_,"mcPuddle",5,{_alpha:60});
  21.       var _loc3_ = !Application.bEasy ? 10 : 8;
  22.       this.delay = 150 - Game.level * _loc3_ + Math.round(30 * Math.random());
  23.    }
  24.    function step(plVel)
  25.    {
  26.       this.pos.y -= plVel.y;
  27.       this.checkBottom();
  28.    }
  29.    function draw()
  30.    {
  31.       this.mcPuddle._x = this.pos.x;
  32.       this.mcPuddle._y = Game.screenH - this.pos.y;
  33.    }
  34.    function remove(Void)
  35.    {
  36.       this.mcPuddle.removeMovieClip();
  37.       false;
  38.    }
  39.    function checkBottom(Void)
  40.    {
  41.       if(this.pos.y < -50)
  42.       {
  43.          this.pos.y = -55;
  44.          if(this.delay-- <= 0)
  45.          {
  46.             Game.getInstance().removePuddle(this);
  47.          }
  48.       }
  49.    }
  50. }
  51.