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

  1. class Engine.PongObject extends GDK.Node
  2. {
  3.    var target;
  4.    var onDisplay;
  5.    var assetID = "square";
  6.    static var FRAME_TIME = Game.PongLevels.FRAME_TIME;
  7.    var className = "PongObject";
  8.    var autoAddToScene = true;
  9.    var width = 0;
  10.    var height = 0;
  11.    var left = 0;
  12.    var right = 0;
  13.    var top = 0;
  14.    var bottom = 0;
  15.    static var RIGHT_DIR = "right";
  16.    static var LEFT_DIR = "left";
  17.    static var __inited = false;
  18.    function PongObject()
  19.    {
  20.       super();
  21.       if(!Engine.PongObject.__inited)
  22.       {
  23.          this.init();
  24.       }
  25.    }
  26.    function onAddToWorld()
  27.    {
  28.       if(this.autoAddToScene)
  29.       {
  30.          this.addToScene();
  31.       }
  32.    }
  33.    function setDisplay()
  34.    {
  35.       this.target._x = this.x;
  36.       this.target._y = this.y;
  37.       this.onDisplay.apply(this,arguments);
  38.    }
  39.    function init()
  40.    {
  41.       mx.events.EventDispatcher.initialize(Engine.PongObject.prototype);
  42.       Engine.PongObject.__inited = true;
  43.    }
  44.    function findIntersection4p(l0p0, l0p1, l1p0, l1p1)
  45.    {
  46.       var _loc3_ = ((l1p1.x - l1p0.x) * (l0p0.y - l1p0.y) - (l1p1.y - l1p0.y) * (l0p0.x - l1p0.x)) / ((l1p1.y - l1p0.y) * (l0p1.x - l0p0.x) - (l1p1.x - l1p0.x) * (l0p1.y - l0p0.y));
  47.       if(0 <= _loc3_ && _loc3_ <= 1)
  48.       {
  49.          return new Vector(l0p0.x + _loc3_ * (l0p1.x - l0p0.x),l0p0.y + _loc3_ * (l0p1.y - l0p0.y),0);
  50.       }
  51.       return null;
  52.    }
  53. }
  54.