示例#1
0
        /// <summary>
        /// Update the internal sate of your game
        /// </summary>
        protected override void UpdateWorld()
        {
            if (GamePad.ButtonBackClicked())
            {
                Exit();
            }

            // move the target
            mTarget.Center += GamePad.ThumbSticks.Right;

            // change the turn rate
            mTurnRate += 0.02f * GamePad.ThumbSticks.Left.X;
            mTurnRate  = MathHelper.Clamp(mTurnRate, 0f, 1f);

            mSocccer.Update(mTarget, mTurnRate);

            EchoToTopStatus("LeftThumb-X: TurnRate(" + mTurnRate + ") RightThumbStick: move target");
        }
示例#2
0
        protected override void UpdateWorld()
        {
            if (GamePad.ButtonBackClicked())
            {
                Exit();
            }

            #region Pause everything
            if (GamePad.ButtonXClicked())
            {
                World.Paused = !World.Paused;
            }

            if (World.Paused)
            {
                return;
            }
            #endregion

            #region shoot the ball
            if (GamePad.ButtonAClicked())
            {
                Vector2 velocity = mVBlock.VelocityDirection * mVBlock.Speed;
                mBall.ShootSoccer(kInitPosition, velocity);
            }
            #endregion

            #region Update Velocity Dir and size by thumbSticks
            mVBlock.UpdateVelocityBlock(GamePad.ThumbSticks.Right, GamePad.ThumbSticks.Left.Y);
            #endregion

            #region tell the Ball to update itself
            mBall.Update();
            #endregion

            #region Rotate the Block
            mBlock.UpdateBlock(Vector2.Zero, GamePad.Triggers.Right);
            #endregion

            EchoToTopStatus("Block rotated angle=" + mBlock.RotateAngle);
            EchoToBottomStatus("Vector Direction" + mVBlock.VelocityDirection + " Size: " + mVBlock.Speed);
        }
示例#3
0
        protected override void UpdateWorld()
        {
            if (GamePad.ButtonBackClicked())
            {
                Exit();
            }

            #region Elasticity and Friction by Left ThumbStick
            mElasticiy += 0.02f * GamePad.ThumbSticks.Left.X;
            mFriction  += 0.02f * GamePad.ThumbSticks.Left.Y;
            #endregion

            if (GamePad.ButtonXClicked())
            {
                World.Paused = !World.Paused;
            }

            if (!World.Paused)
            {
                #region shoot the ball
                if (GamePad.ButtonAClicked())
                {
                    Vector2 velocity = mVBlock.VelocityDirection * mVBlock.Speed;
                    mBall.ShootSoccer(kInitPosition, velocity);
                }
                #endregion

                #region Update Velocity Dir and size by Right thumbStick
                mVBlock.UpdateVelocityBlock(GamePad.ThumbSticks.Right);
                #endregion

                #region tell the Ball to update itself
                mBall.Update(mElasticiy, mFriction);
                #endregion

                #region Rotate the Block
                mBlock.UpdateBlock(Vector2.Zero, GamePad.Triggers.Right);
                #endregion
            }
            EchoToTopStatus("Elasticity[LeftThumb.X]=" + mElasticiy + "  Friction[LeftThumb.Y]=" + mFriction);
            EchoToBottomStatus("Vector Direction" + mVBlock.VelocityDirection + " Size: " + mVBlock.Speed);
        }
示例#4
0
        protected override void UpdateWorld()
        {
            if (GamePad.ButtonBackClicked())
            {
                Exit();
            }

            #region add a new road segment
            if (GamePad.ButtonAClicked())
            {
                mRoad.FinalizeRoadSegment(mDir, mLength);
            }
            #endregion

            #region Update vectorDir and size by thumbSticks
            mDir           += GamePad.ThumbSticks.Right;
            mLength        += GamePad.ThumbSticks.Left.Y;
            mTicksToTravel += GamePad.ThumbSticks.Left.X;
            mRoad.UpdateRoadSegment(mDir, mLength);
            mBall.TopOfAutoDrawSet();
            #endregion

            #region tell the Ball to update itself
            mTicksHasPassed++;
            if (mBall.Update(mTicksToTravel))
            {
                mTicksHasPassed = 0;
            }
            #endregion

            #region restart ...
            if (GamePad.ButtonBClicked())
            {
                mRoad.ResetRoad();
                mBall.ResetBallPosition();
            }
            #endregion

            EchoToTopStatus("Number of updates to travel each segment:" + mTicksToTravel + "  NumHasPassed(" + mTicksHasPassed + ")");
            EchoToBottomStatus("Vector Direction" + mDir + " Size: " + mLength);
        }