Exemplo n.º 1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp);

            switch (Stat)
            {
            case Stat.SplashScreen:

                break;

            case Stat.Game:
                BattleCity.Draw();

                //          tank1.Draw(spriteBatch);
                break;

            case Stat.GameOver:

                break;

            case Stat.Pause:

                break;
            }



            spriteBatch.End();

            // TODO: Add your drawing code here

            base.Draw(gameTime);
        }
Exemplo n.º 2
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)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            switch (Stat)
            {
            case Stat.SplashScreen:
                if (Keyboard.GetState().IsKeyDown(Keys.Enter))
                {
                    Stat = Stat.Game;
                }
                break;

            case Stat.Game:
                BattleCity.UpdateBullet();
                BattleCity.CheckHit();

                if (Keyboard.GetState().IsKeyDown(Keys.H))
                {
                    BattleCity.AddTank(tank);
                }

                if (Keyboard.GetState().IsKeyDown(Keys.Space))
                {
                    BattleCity.Player.Fire(sprites);
                }

                if (Keyboard.GetState().IsKeyDown(Keys.Up))
                {
                    BattleCity.Update(Direction.Up);
                }
                else if (Keyboard.GetState().IsKeyDown(Keys.Down))
                {
                    BattleCity.Update(Direction.Down);
                }
                else if (Keyboard.GetState().IsKeyDown(Keys.Left))
                {
                    BattleCity.Update(Direction.Left);
                }
                else if (Keyboard.GetState().IsKeyDown(Keys.Right))
                {
                    BattleCity.Update(Direction.Right);
                }
                break;

            case Stat.GameOver:

                break;

            case Stat.Pause:

                break;
            }



            base.Update(gameTime);
        }