Ejemplo 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)
        {
            switch (currentScreen)
            {
            case menuScreen:
                spriteBatch.Begin();
                spriteBatch.Draw(background, GraphicsDevice.Viewport.Bounds, Color.White);
                if (playGameButton.update(new Vector2(newMouseState.X, newMouseState.Y)) == true)
                {    //If mouse is in playbutton range, draw white box around it
                    spriteBatch.Draw(window, new Rectangle(199, 99, 302, 52), Color.White);
                }
                spriteBatch.Draw(playGame, new Rectangle(200, 100, 300, 50), Color.White);
                spriteBatch.Draw(options, new Rectangle(600, 100, options.Width, options.Height), Color.White);
                spriteBatch.End();
                break;

            case game:
                GraphicsDevice.Clear(Color.Gray);
                List <int[, ]> GameBoardList = gbObj.GetGameBoard();
                Color          boardColor    = new Color();
                bool           boardShape    = true;
                bool           nextShape     = false;
                gameBoard = GameBoardList[0];
                //Game board
                spriteBatch.Begin();
                spriteBatch.Draw(space, GraphicsDevice.Viewport.Bounds, Color.White);
                for (int i = 0; i < 10; i++)
                {
                    for (int j = 0; j < 18; j++)
                    {
                        if (gameBoard[i, j] == 0)
                        {
                            boardColor = Color.FromNonPremultiplied(50, 50, 50, 50);
                            spriteBatch.Draw(block, new Rectangle(boardX + i * size, boardY + j * size, size, size), new Rectangle(0, 0, 32, 32), Color.DarkGray);
                        }
                    }
                }
                spriteBatch.End();
                gbObj.UpdateBoard(loadedBoard, block, spriteBatch);


                //Drawing the shape to go onto the board
                spriteBatch.Begin();
                drawShape(boardShape);
                spriteBatch.End();


                //display the score, level, and lines cleared
                spriteBatch.Begin();
                spriteBatch.DrawString(font, "Score: " + score, new Vector2(700, 200), Color.White);
                spriteBatch.DrawString(font, "Level: " + level, new Vector2(700, 300), Color.White);
                spriteBatch.DrawString(font, "Lines Cleared: " + linesCleared, new Vector2(50, 200), Color.White);
                spriteBatch.End();

                //Next block square
                spriteBatch.Begin();
                spriteBatch.DrawString(font, "Next Block", new Vector2(700, 400), Color.White);
                spriteBatch.Draw(window, new Rectangle(700, 450, 200, 200), Color.Gray);
                drawShape(nextShape);
                spriteBatch.End();

                break;
            }
            base.Draw(gameTime);
        }