/* This class makes a platform. Its constructor takes a position; that is where the platform stays. It provides two functions; collides and onIt collides returns 1 when an object is both near its top and going down fast enough to be about to go through the platform onit returns 1 when an object is near to it-- use for jumping */ package { import flash.display.Sprite; public class platform extends Sprite { private var mySymbol : platformSymbol; private var px, py: Number; // the top-left corner of the platform private const myWidth=100; // make sure the symbol is 100 pix wide! // constructor. makes platform appear in the right place public function platform(myX, myY: Number) { mySymbol = new platformSymbol(); mySymbol.x = myX; mySymbol.y = myY; addChild(mySymbol); px = myX; py = myY; } // return 1 if you're going to hit the platform next step public function collides(myX, myY, myyv:Number):int { if ( (myX>px) && (myX<(px+myWidth))) { if ((myYpy)) { return 1; } } return 0; } // return 1 if you're +/-20 pixels over/under the platform public function onIt(myX, myY:Number):int { if ( (myX>px) && (myX<(px+myWidth))) { if (Math.abs(myY-py)<20.0) { return 1; } } return 0; } } }