Beispiel #1
0
        /// <summary>
        /// Starts a game
        /// </summary>
        void StartGame()
        {
            // randomly generate new number for game
            //59. In the StartGame method, declare a variable to hold the correct number for the current game and set it to
            //    a random number (from 1 to 9 inclusive) you generate using the field from the previous step. Pass that
            //    number as the correct number argument when you call the NumberBoard constructor in the StartGame
            //    method (Chapter 4, Week 2)
            int number = rand.Next(1, 10);



            //55. Cut the code you added to the Game1 LoadContent method to calculate the board size and actually
            //    create the board and paste that code into the StartGame method I provided at the end of the Game1
            //    class. Call the StartGame method from the Game1 LoadContent method where you used to have that
            //        code. You'll see why we need to do this soon (Chapter 4, Week 2)

            // create the board object (this will be moved before you're done)
            int sideLength = 0;

            if (graphics.PreferredBackBufferWidth < graphics.PreferredBackBufferHeight)
            {
                sideLength = graphics.PreferredBackBufferWidth;
            }
            else
            {
                sideLength = graphics.PreferredBackBufferHeight;
            }
            Vector2 center = new Vector2((WINDOW_WIDTH / 2), (WINDOW_HEIGHT / 2));

            // 64. In the StartGame method, pass the sound bank as the sound bank argument to the NumberBoard
            //    constructor (instead of the null you’ve been passing) (Chapter 4, Week 2)

            numberBoard = new NumberBoard(Content, center, (int)(sideLength * 0.8), number, soundBank);
        }
        /// <summary>
        /// Starts a game
        /// </summary>
        void StartGame()
        {
            // randomly generate new number for game
            Random rand          = new Random();
            int    correctNumber = rand.Next(9) + 1;

            // create the board object (this will be moved before you're done)
            numberBoard = new NumberBoard(Content, new Vector2(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2), 400, correctNumber, soundBank);
        }
        /// <summary>
        /// Starts a game
        /// </summary>
        void StartGame()
        {
            // randomly generate new number for game
            int correctNumber = rand.Next(1, 10);

            // create the board object (this will be moved before you're done)

            numberBoard = new NumberBoard(Content, boardCenter, sideLength, correctNumber, soundBank);
        }
Beispiel #4
0
        /// <summary>
        /// Starts a game
        /// </summary>
        void StartGame()
        {
            // randomly generate new number for game
            int currentNumber = random.Next(1, 10);

            // creating the board, the length of the board is half the size of WINDOW_HEIGHT
            Vector2 center    = new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2);
            int     boardSize = Math.Min(WINDOW_WIDTH, WINDOW_HEIGHT);

            board = new NumberBoard(Content, center, boardSize / 2, currentNumber, soundBank);
        }
Beispiel #5
0
        /// <summary>
        /// Starts a game
        /// </summary>
        void StartGame()
        {
            // randomly generate new number for game
            rand = new Random((int)DateTime.Now.Ticks & 0x0000FFFF);

            // create the board object (this will be moved before you're done)
            // Increment 2: create the board object (this will be moved before you're done with the project)
            numberBoard = new NumberBoard(Content,
                                          new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2),
                                          500,
                                          rand.Next(1, 9),
                                          soundBank);
        }
        /// <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);

            // load audio content

            // Increment 1: load opening screen and set opening screen draw rectangle

            openingScreenTexture = Content.Load <Texture2D>("openingscreen");
            openingScreenRec     = new Rectangle(0, 0,
                                                 openingScreenTexture.Width, openingScreenTexture.Height);

            // Increment 2: create the board object (this will be moved before you're done with the project)
            numberBoard = new NumberBoard(Content, new Vector2(0, 0), HEIGHT_RESOLUTION / 2, 8, null);
        }
        /// <summary>
        /// Starts a game
        /// </summary>
        void StartGame()
        {
            // randomly generate new number for game
            int correctNumber = randomNumber.Next(1, 10);

            // create the board object (this will be moved before you're done)
            // The board should be centered in the window and should be smaller
            // than the window width and height.
            Vector2 center = new Vector2();

            center.X = WINDOW_WIDTH / 2;
            center.Y = WINDOW_HEIGHT / 2;

            // I take away 0.2 part of the height window
            int sideLength = (int)(WINDOW_HEIGHT * 0.8);

            numberBoard = new NumberBoard(Content, center, sideLength, correctNumber, soundBank);
        }
Beispiel #8
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);

            // load audio content

            // Increment 1: load opening screen and set opening screen draw rectangle
            openingScreen           = Content.Load <Texture2D>("openingscreen");
            openingScreenRectangle0 = new Rectangle(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);

            // Increment 2: create the board object (this will be moved before you're done with the project)
            // find vector2 and center x,y
            //center = new Vector2(xVal,yVal);
            center = new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2);

            //create numberboard
            //numberBoard = new NumberBoard(Content, center, WINDOW_WIDTH, 8, null);
            numberBoard = new NumberBoard(Content, center, (int)(graphics.PreferredBackBufferHeight * 0.8), 8, null);
        }
Beispiel #9
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);

            // load audio content

            // Increment 1: load opening screen and set opening screen draw rectangle
            openingScreen        = Content.Load <Texture2D>("openingscreen");
            drawRectangle        = new Rectangle();
            drawRectangle.Height = graphics.PreferredBackBufferHeight;
            drawRectangle.Width  = graphics.PreferredBackBufferWidth;

            // Increment 2: create the board object (this will be moved before you're done with the project)
            int     boardSideLength = WINDOW_HEIGHT - 50;
            int     boardCenterX    = WINDOW_WIDTH / 2;
            int     boardCenterY    = WINDOW_HEIGHT / 2;
            Vector2 boardCenter     = new Vector2(boardCenterX, boardCenterY);

            numberBoard = new NumberBoard(Content, boardCenter, boardSideLength, 8, null);
        }
        /// <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);

            // load audio content

            // Increment 1: load opening screen and set opening screen draw rectangle
            openingScreen = Content.Load<Texture2D>("openingscreen");
            drawRectangle = new Rectangle();
            drawRectangle.Height = graphics.PreferredBackBufferHeight;
            drawRectangle.Width = graphics.PreferredBackBufferWidth;

            // Increment 2: create the board object (this will be moved before you're done with the project)
            int boardSideLength = WINDOW_HEIGHT - 50;
            int boardCenterX = WINDOW_WIDTH / 2;
            int boardCenterY = WINDOW_HEIGHT / 2;
            Vector2 boardCenter = new Vector2(boardCenterX, boardCenterY);
            numberBoard = new NumberBoard(Content, boardCenter, boardSideLength, 8, null);
        }
Beispiel #11
0
        /// <summary>
        /// Starts a game
        /// </summary>
        void StartGame()
        {
            // randomly generate new number for game
            int correctNumber = rand.Next(1, 10);

            // Increment 2: create the board object (this will be moved before you're done with the project)
            // Set center point
            float centerX = graphics.PreferredBackBufferWidth / 2.0f;
            float centerY = graphics.PreferredBackBufferHeight / 2.0f;
            Vector2 center = new Vector2(centerX, centerY);

            // Set board length less than height of window
            int boardLength = graphics.PreferredBackBufferHeight - 100;
            numberBoard = new NumberBoard(Content, center, boardLength, correctNumber, soundBank);
        }
Beispiel #12
0
 /// <summary>
 /// Starts a game
 /// </summary>
 void StartGame()
 {
     // randomly generate new number for game
     int Rnum = randomNum.Next(1,10) ;
     // create the board object (this will be moved before you're done)
     board = new NumberBoard(Content,
          new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2),
          (int)(graphics.PreferredBackBufferHeight * 0.8), Rnum,soundBank);
 }
Beispiel #13
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);

            // load audio content

            // Increment 1: load opening screen and set opening screen draw rectangle

            openingScreenTexture = Content.Load<Texture2D>("openingscreen");
            openingScreenRec = new Rectangle(0, 0,
                openingScreenTexture.Width, openingScreenTexture.Height);

            // Increment 2: create the board object (this will be moved before you're done with the project)
            numberBoard = new NumberBoard(Content, new Vector2(0, 0), HEIGHT_RESOLUTION / 2, 8, null);
        }