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

            switch (GameElements.currentState)
            {
            case GameElements.State.Run:
                GameElements.currentState = GameElements.RunUppdate(Content, Window, gameTime);
                break;

            case GameElements.State.HighScore:
                GameElements.currentState = GameElements.HighScoreUpdate();
                break;

            case GameElements.State.Quit:
                this.Exit();
                break;

            default: GameElements.currentState = GameElements.MenuUpdate(gameTime);
                break;
            }

            base.Update(gameTime);
        }
Exemplo n.º 2
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)
        {
            /*for (int x = 0; x < Window.ClientBounds.Width; x += 200)
             * {
             *  for (int y = 0; y < Window.ClientBounds.Height; y += 200)
             *  {
             *      spriteBatch.Draw(backround, new Vector2(x, y), Color.White);
             *  }
             * }*/

            GraphicsDevice.Clear(Color.Gray);

            spriteBatch.Begin();

            switch (GameElements.currentState)
            {
            case GameElements.State.Run:
                GameElements.RunDraw(spriteBatch);
                break;

            case GameElements.State.HighScore:
                GameElements.HighScoreDraw(spriteBatch);
                break;

            case GameElements.State.Quit:
                this.Exit();
                break;

            default:
                GameElements.MenuDraw(spriteBatch);
                break;
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemplo n.º 3
0
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     // Create a new SpriteBatch, which can be used to draw textures.
     spriteBatch = new SpriteBatch(GraphicsDevice);
     GameElements.LoadContent(Content, Window);
 }