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

  1. class cBall
  2. {
  3.    var mc;
  4.    var halfWidth;
  5.    var normWidth;
  6.    var normHeight;
  7.    var speed;
  8.    var dy;
  9.    var state;
  10.    var ffloor;
  11.    var col = 0;
  12.    var sideSpeed = 30;
  13.    static var stNormal = 0;
  14.    static var stPower = 1;
  15.    static var stSize = 2;
  16.    function cBall(_mc)
  17.    {
  18.       this.mc = _mc;
  19.       this.halfWidth = Math.floor(this.mc._width / 2);
  20.       this.normWidth = this.mc._width;
  21.       this.normHeight = this.mc._height;
  22.    }
  23.    function normSize()
  24.    {
  25.       this.mc._height = 0.7 * this.normHeight;
  26.       this.mc._width = 0.7 * this.normWidth;
  27.    }
  28.    function start(sp)
  29.    {
  30.       this.normSize();
  31.       this.mc._x = _root.posX;
  32.       this.mc._y = _root.posY;
  33.       this.speed = sp;
  34.       this.dy = 1;
  35.       this.state = cBall.stNormal;
  36.       this.ffloor = false;
  37.    }
  38.    function moveLeft()
  39.    {
  40.       var _loc3_ = 0;
  41.       while(_loc3_ < this.sideSpeed && this.mc._x > this.halfWidth)
  42.       {
  43.          this.mc._x--;
  44.          _loc3_ = _loc3_ + 1;
  45.       }
  46.       _root.checkPos();
  47.    }
  48.    function moveRight()
  49.    {
  50.       var _loc3_ = 0;
  51.       while(_loc3_ < this.sideSpeed && this.mc._x < Stage.width - this.halfWidth)
  52.       {
  53.          this.mc._x = this.mc._x + 1;
  54.          _loc3_ = _loc3_ + 1;
  55.       }
  56.       _root.checkPos();
  57.    }
  58.    function move()
  59.    {
  60.       if(this.dy == -1)
  61.       {
  62.          this.mc._y = _root.beam.leftBeam._y - this.mc._height / 2 - _root.beam.leftBeam._height / 2;
  63.       }
  64.       else if(this.mc._y >= Stage.height - this.mc._height / 2 - 5 && this.dy > 0)
  65.       {
  66.          this.dy = 0;
  67.          this.mc._y = Stage.height - this.mc._height / 2;
  68.          this.ffloor = true;
  69.       }
  70.       if(this.mc._y < Stage.height - this.mc._height / 2 - 5)
  71.       {
  72.          this.ffloor = false;
  73.       }
  74.       this.mc._y += this.dy;
  75.       _root.checkPos();
  76.    }
  77.    function makePower()
  78.    {
  79.       var _loc2_ = new Color(this.mc.inside_mc);
  80.       _loc2_.setRGB(52224);
  81.       this.state = cBall.stPower;
  82.    }
  83.    function unmake()
  84.    {
  85.       if(this.state == cBall.stSize)
  86.       {
  87.          this.speed = _root.ballSpeed;
  88.       }
  89.       this.state = cBall.stNormal;
  90.       this.mc._height = 0.7 * this.normHeight;
  91.       this.mc._width = 0.7 * this.normWidth;
  92.       this.halfWidth = Math.floor(this.mc._width / 2);
  93.       var _loc3_ = new Color(this.mc.inside_mc);
  94.       _loc3_.setRGB(this.col);
  95.    }
  96.    function makeSize()
  97.    {
  98.       this.state = cBall.stSize;
  99.       this.mc._height = this.normHeight;
  100.       this.mc._width = this.normWidth;
  101.       this.halfWidth = Math.floor(this.mc._width / 2);
  102.    }
  103. }
  104.