home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / Survival.swf / scripts / Block.as < prev    next >
Encoding:
Text File  |  2008-09-04  |  1.3 KB  |  56 lines

  1. package
  2. {
  3.    import flash.display.Sprite;
  4.    
  5.    [Embed(source="/_assets/assets.swf", symbol="Block")]
  6.    public class Block extends Sprite
  7.    {
  8.        
  9.       
  10.       public function Block()
  11.       {
  12.          super();
  13.          x = Math.random() * 720;
  14.          y = Math.random() * 480;
  15.          width = 22 + Math.random() * 70;
  16.          height = 22 + Math.random() * 70;
  17.       }
  18.       
  19.       internal function collision(param1:Actor) : *
  20.       {
  21.          var _loc2_:int = 0;
  22.          while(hitTestObject(param1) && _loc2_ < 50)
  23.          {
  24.             _loc2_++;
  25.             if(param1.velx != 0 || param1 is Zombie)
  26.             {
  27.                if(param1.x < x)
  28.                {
  29.                   --param1.x;
  30.                }
  31.                if(param1.x > x)
  32.                {
  33.                   ++param1.x;
  34.                }
  35.             }
  36.             if(param1.vely != 0 || param1 is Zombie)
  37.             {
  38.                if(param1.y < y)
  39.                {
  40.                   --param1.y;
  41.                }
  42.                if(param1.y > y)
  43.                {
  44.                   ++param1.y;
  45.                }
  46.             }
  47.             if(param1.velx == 0 && param1.vely == 0)
  48.             {
  49.                ++param1.x;
  50.                ++param1.y;
  51.             }
  52.          }
  53.       }
  54.    }
  55. }
  56.