home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Classicos / smashout.swf / scripts / __Packages / Game / Objects / CollisionObject.as < prev    next >
Encoding:
Text File  |  2005-11-09  |  1.4 KB  |  39 lines

  1. class Game.Objects.CollisionObject extends Engine.PongObject
  2. {
  3.    var edges;
  4.    static var EDGE_DEFAULT = 0;
  5.    static var EDGE_COLLISION = 1;
  6.    function CollisionObject()
  7.    {
  8.       super();
  9.    }
  10.    function createEdges(TL, TR, BR, BL)
  11.    {
  12.       this.edges = [new _types_.ShapeEdge(TL,TR),new _types_.ShapeEdge(TR,BR),new _types_.ShapeEdge(BR,BL),new _types_.ShapeEdge(BL,TL)];
  13.       var _loc3_ = undefined;
  14.       var _loc4_ = undefined;
  15.       var _loc2_ = undefined;
  16.       var _loc5_ = this.edges.length;
  17.       while((_loc5_ = _loc5_ - 1) > -1)
  18.       {
  19.          _loc3_ = _loc2_ = this.edges[_loc5_].a;
  20.          _loc4_ = _loc2_.b;
  21.          _loc2_.center = new Vector(_loc3_.x + (_loc4_.x - _loc3_.x) * 0.5,_loc3_.y + (_loc4_.y - _loc3_.y) * 0.5);
  22.          _loc2_.radius = 0.5 * (_loc2_.length = _loc2_.span = new Vector(_loc4_.x - _loc3_.x,_loc4_.y - _loc3_.y).length);
  23.          _loc2_.direction = _loc2_.span.getNormalized();
  24.          _loc2_.normal = _loc2_.direction.cross();
  25.          _loc2_.angle = Math.atan2(_loc2_.direction.y,_loc2_.direction.x);
  26.          _loc2_.props = _loc4_.props;
  27.       }
  28.    }
  29.    function angleToVector(angle)
  30.    {
  31.       var _loc1_ = angle / 180 * 3.141592653589793;
  32.       return new Vector(Math.sin(_loc1_),- Math.cos(_loc1_),0);
  33.    }
  34.    function vectorToAngle(v)
  35.    {
  36.       return Math.atan2(v.y,v.x) / 3.141592653589793 * 180 + 90;
  37.    }
  38. }
  39.