public override void EnterFrame()
        {
            base.EnterFrame();
            EPointF loc = this.ConvParentLocToRootLoc(Loc);

            m_rctWrap.WrapPointInside(loc);
            Loc = this.ConvRootLocToParentLoc(loc);
        }
Exemple #2
0
        public override void EnterFrame()
        {
            base.EnterFrame();

            ERectangleF rct = new ERectangleF(0, 0, 640, 480);
            EPointF     loc = this.ConvParentLocToRootLoc(Loc);

            rct.WrapPointInside(loc);
            Loc = this.ConvRootLocToParentLoc(loc);
        }
Exemple #3
0
        public override void EnterFrame()
        {
            float minStep = (float)Math.PI / 32;

            if (this._keys.GetKeyActive("right"))
            {
                this._inputSteerAngle = Math.Max(this._inputSteerAngle - minStep, -(float)Math.PI / 4);
            }
            if (this._keys.GetKeyActive("left"))
            {
                this._inputSteerAngle = Math.Min(this._inputSteerAngle + minStep, (float)Math.PI / 4);
            }

            if (this._inputSteerAngle > 0)
            {
                this._inputSteerAngle -= minStep / 4;
                if (this._inputSteerAngle < 0)
                {
                    this._inputSteerAngle = 0;
                }
            }
            else if (this._inputSteerAngle < 0)
            {
                this._inputSteerAngle += minStep / 4;
                if (this._inputSteerAngle > 0)
                {
                    this._inputSteerAngle = 0;
                }
            }

            if (this._keys.GetKeyActive("up"))
            {
                this._targetSpeed  += 1;
                this._inputThrottle = Math.Min(this._inputThrottle + 10, 100f);
            }
            else if (this._keys.GetKeyActive("down"))
            {
                this._targetSpeed  -= 1;
                this._inputThrottle = Math.Max(this._inputThrottle - 10, -60f);
            }
            else
            {
                if (localVel.X > 0)
                {
                    if (localVel.X > 0.5f)
                    {
                        this._inputThrottle = -25;
                    }
                    else if (this._inputThrottle == 0)
                    {
                        this._velocity = new EPointF();
                    }
                }
            }

            //if (this.Velocity.Length < this._targetSpeed)
            //    this._inputThrottle = 30;
            //else if (this.Velocity.Length > this._targetSpeed)
            //    this._inputThrottle = -30;

            if (this._inputThrottle > 0)
            {
                this._inputThrottle -= 5;
            }
            else if (this._inputThrottle < 0)
            {
                this._inputThrottle += 5;
            }

            if (this._keys.GetKeyActive("action"))
            {
                this._inputBrake    = 100;
                this._inputThrottle = 0;
            }
            else
            {
                this._inputBrake = 0;
            }

            if (this._lastFrameTicks > 0)
            {
                int timeDelta = (int)(DateTime.Now.Ticks - this._lastFrameTicks);
                if (timeDelta > 0)
                {
                    //this.DoPhysics(10);
                    this.DoPhysics(timeDelta / 10000);
                }
            }
            this._lastFrameTicks = DateTime.Now.Ticks;
            this.Rotation        = -this._angle;
            ERectangleF rct = new ERectangleF(new EPointF(), EH.Instance.Stage.ControlSize.ToEPointF());
            EPointF     loc = this.Loc.Copy();

            rct.WrapPointInside(loc);
            this.Loc = loc;

            base.EnterFrame();
        }