Example #1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }



            GamePadState currentState = GamePad.GetState(PlayerIndex.One);

            // Process input only if connected.
            if (currentState.IsConnected)
            {
                // Increase vibration if the player is tapping the A button.
                // Subtract vibration otherwise, even if the player holds down A
                if (currentState.Buttons.Y == ButtonState.Pressed && resetLevel == false)
                {
                    camX = camY = 0;
                    nextLevel();
                    resetLevel = true;
                }
                else if (currentState.Buttons.Y != ButtonState.Pressed)
                {
                    resetLevel = false;
                }
            }

            // TODO: Add your update logic here
            KeyboardState keyState = Keyboard.GetState();

            if (keyState.IsKeyUp(Keys.R))
            {
                resetLevel = false;
            }
            if (keyState.IsKeyDown(Keys.R) && resetLevel == false)
            {
                camX = camY = 0;
                nextLevel();
                resetLevel = true;
            }



            if (keyState.IsKeyDown(Keys.Q))
            {
                UnloadContent();
            }

            if (keyState.IsKeyDown(Keys.Left))
            {
                MyCircle.keyPressed(Keys.Left);
            }
            else if (keyState.IsKeyDown(Keys.Right))
            {
                MyCircle.keyPressed(Keys.Right);
            }
            if (keyState.IsKeyDown(Keys.Up))
            {
                MyCircle.keyPressed(Keys.Up);
            }
            if (keyState.IsKeyDown(Keys.R))
            {
                //this.Run();
                //Initialize();
            }


            /*if (keyState.IsKeyDown(Keys.Down))
             * {
             *  MyCircle.keyPressed(Keys.Down);
             * }*/


            if (MyCircle.starStatus() || MyCircle2.starStatus() || MyCircle3.starStatus() || MyCircle4.starStatus())
            {
                nextLevel();
            }

            MyCircle.update();
            MyCircle2.update();
            MyCircle3.update();
            MyCircle4.update();


            base.Update(gameTime);
        }