Пример #1
0
 /// <summary>
 /// Update the game over screen
 /// </summary>
 /// <param name="gameTime">Time since the last update</param>
 public override void Update(GameTime gameTime)
 {
     // Space key to play again
     if (Keyboard.KeyPressed(Keys.Space) || Mouse.Button1Pressed())
     {
         //todo: also do this for phone tap
         //todo: also do this for xbox a button
         ShowScene("title");
     }
 }
Пример #2
0
        /// <summary>
        /// Update the title screen
        /// </summary>
        public override void Update(GameTime gameTime)
        {
            if (Keyboard.KeyPressed(Keys.Right))
            {
                SpaceInvaders.NumberOfPlayers  = 2;
                Player1StartText.AnimationType = TextAnimations.None;
                Player1StartText.Scale         = 0.6f;
                Player2StartText.AnimationType = TextAnimations.Throb;
                Player2StartText.Scale         = 0.6f;
                Player2StartText.Start();
            }

            if (Keyboard.KeyPressed(Keys.Left))
            {
                SpaceInvaders.NumberOfPlayers  = 1;
                Player1StartText.AnimationType = TextAnimations.Throb;
                Player1StartText.Scale         = 0.6f;
                Player2StartText.AnimationType = TextAnimations.None;
                Player2StartText.Scale         = 0.6f;
                Player1StartText.Start();
            }

            // Space key starts the game
            if (Keyboard.KeyPressed(Keys.Space) || Mouse.Button1Pressed())
            {
                ((SpaceInvaders)Game).CreatePlayerScreens();
                ShowScene("Player1");
            }

            // Give us something interesting to look at
            // by just making the high score go mad
            // (wait until it has been added to the screen)
            if (HighScoreText != null)
            {
                HighScoreText.Value = "High Score: " + SpaceInvaders.HighScore;
            }
        }
Пример #3
0
        /// <summary>
        /// Update the game over screen
        /// </summary>
        /// <param name="gameTime">Time since the last update</param>
        public override void Update(GameTime gameTime)
        {
            if (Mouse.Button1Pressed())
            {
                ufo.RotateTowards(Mouse.Position, 90);
                ufo.GlideTo(Mouse.Position, 2f);
            }

            barrier.SpriteColor = barrier.IsTouching(Mouse.Position) ?
                                  Color.Green : Color.Aqua;

            // Space key to play again
            if (Keyboard.KeyPressed(Keys.Space))
            {
                //todo: also do this for phone tap
                //todo: also do this for xbox a button
                ShowScene("play");
            }

            if (missile != null)
            {
                missile.Rotation   += .5f;
                missile.SpriteColor = ufo.IsTouching(missile) ? Color.Red : Color.Green;
            }
            if (ufo != null)
            {
                ufo.DirectionFrom(Keyboard, 2);
                if (Keyboard.KeyDown(Keys.Z))
                {
                    ufo.Rotation += 1f;
                }
                if (Keyboard.KeyDown(Keys.X))
                {
                    ufo.Rotation -= 1f;
                }
            }
        }