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.Aquamarine);


            switch (gamestate)
            {
            case Gamestate.Alive: Gamestate1.Draw(spriteBatch, GraphicsDevice); return;

            case Gamestate.Dead: Gamestate2.Draw(spriteBatch, GraphicsDevice); return;
            }



            // 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();
            }
            if (Keyboard.HasBeenPressed(Keys.F11))
            {
                if (graphics.IsFullScreen)
                {
                    graphics.IsFullScreen              = false;
                    graphics.PreferredBackBufferWidth  = 800;
                    graphics.PreferredBackBufferHeight = 600;
                }
                else
                {
                    graphics.IsFullScreen              = true;
                    graphics.PreferredBackBufferWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; // set this value to the desired width of your window
                    graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
                }
                graphics.ApplyChanges();
            }

            switch (gamestate)
            {
            case Gamestate.Alive: Gamestate1.Update(Window, Content, graphics, GraphicsDevice); return;

            case Gamestate.Dead:
                if (!gamestate2Loaded)
                {
                    Gamestate2.LoadContent(Content);
                    gamestate2Loaded = true;
                }
                Gamestate2.Update(Window, Content, graphics, GraphicsDevice);
                return;
            }



            // TODO: Add your update logic here
            base.Update(gameTime);
        }