home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Diversos / painter_madness.swf / scripts / __Packages / cBeam.as < prev    next >
Encoding:
Text File  |  2006-06-13  |  1.6 KB  |  69 lines

  1. class cBeam
  2. {
  3.    var leftBeam;
  4.    var rightBeam;
  5.    var beamWidth;
  6.    var sizeY;
  7.    var sizeX;
  8.    var y;
  9.    var dy;
  10.    var inc;
  11.    var kind;
  12.    var x;
  13.    static var stSolid = 0;
  14.    static var stSoft = 1;
  15.    function cBeam(mc1, mc2)
  16.    {
  17.       this.leftBeam = mc1;
  18.       this.rightBeam = mc2;
  19.       this.beamWidth = mc1._width;
  20.       this.sizeY = Stage.height + 100;
  21.       this.sizeX = Stage.width - 50;
  22.       trace(this.sizeX);
  23.       this.y = this.sizeY;
  24.       this.dy = -5;
  25.       this.inc = false;
  26.       this.kind = cBeam.stSolid;
  27.       this.newPos();
  28.    }
  29.    function newPos()
  30.    {
  31.       this.x = Math.round(Math.random() * this.sizeX);
  32.       if(this.x % 3 == 0)
  33.       {
  34.          this.kind = cBeam.stSoft;
  35.          this.leftBeam.gotoAndStop(2);
  36.          this.rightBeam.gotoAndStop(2);
  37.       }
  38.       else
  39.       {
  40.          this.kind = cBeam.stSolid;
  41.          this.leftBeam.gotoAndStop(1);
  42.          this.rightBeam.gotoAndStop(1);
  43.       }
  44.       trace(this.x);
  45.       this.leftBeam._x = _root.offsetX + this.x - _root.holeHalfWidth;
  46.       this.rightBeam._x = _root.offsetX + this.x + _root.holeHalfWidth;
  47.       this.leftBeam._y = this.y;
  48.       this.rightBeam._y = this.y;
  49.    }
  50.    function move()
  51.    {
  52.       this.y = this.y - 1;
  53.       this.leftBeam._y = this.y;
  54.       this.rightBeam._y = this.y;
  55.       if(this.y < 0)
  56.       {
  57.          this.y = this.sizeY;
  58.          this.newPos();
  59.       }
  60.       _root.checkPos();
  61.    }
  62.    function hide()
  63.    {
  64.       this.y = this.sizeY;
  65.       this.leftBeam._y = this.y;
  66.       this.rightBeam._y = this.y;
  67.    }
  68. }
  69.