package meyermike
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.Rectangle;

    /**
     * ...
     * @author Mike Meyer
     */
    public class GameObject extends Sprite
    {
        public var dx:Number = 0.0;
        public var dy:Number = 0.0;
        public var dr:Number = 0.0;
        protected var mCurBeat:Number;

        public function Init():void
        {
            mCurBeat = 0;
            this.x = 0.0;
            this.y = 0.0;
            this.dx = 0.0;
            this.dy = 0.0;
        }

        public function Integrate(elapsedTime:Number):void
        {
            this.x += dx * elapsedTime;
            this.y += dy * elapsedTime;
            this.rotation += dr * elapsedTime;
        }


        public function Update(elapsedTime:Number):void
        {
        }

        public function Beat(beat:Number):void
        {
            ++mCurBeat;
        }

        public function OffBeat(beat:Number):void
        {
        }

        public function QuarterBeat(quarterBeat:Number):void
        {
        }
        
        /**
         * called after all the final positions have been figured 
         * just before drawing
         */
        public function PreDraw():void
        {
        }
        
        /**
         * Get the collision bounds for collision testing
         */
        public function GetCollisionBounds():Rectangle
        {
            return this.getBounds(this.root);
        }

        /**
         * by default a GO never dies
         */
        public function IsAlive():Boolean
        {
            return true;
        }

        public function Shutdown():void
        {
        }
        
        /**
         * for spherical collision tests
         */
        public function GetCollisionRadius():Number
        {
            return 0.5 * this.width;
        }
    }

}