/// <summary>
        /// Constructor
        /// </summary>
        /// <param name="contentManager">the content manager</param>
        /// <param name="center">the center of the board</param>
        /// <param name="sideLength">the side length for the board</param>
        /// <param name="correctNumber">the correct number</param>
        /// <param name="soundBank">the sound bank for sound effects</param>
        public NumberBoard(ContentManager contentManager, Vector2 center, int sideLength,
                           int correctNumber, SoundBank soundBank)
        {
            // load content for the board and create draw rectangle
            LoadContent(contentManager);
            drawRectangle = new Rectangle((int)(center.X - sideLength / 2),
                                          (int)(center.Y - sideLength / 2), sideLength, sideLength);

            // calculate side length for number tiles
            // Thanks to the picture in the pdf file we can assume that
            // sideLenght = NUM_COLUMNS * tileSideLength + (NUM_COLUMNS + 1) * BORDER_SIZE then
            tileSideLength = (sideLength - ((NUM_COLUMNS + 1) * BORDER_SIZE)) / NUM_COLUMNS;

            // initialize array of number tiles
            int tileNumber = 1;

            for (int row = 0; row < NUM_ROWS; row++)
            {
                for (int column = 0; column < NUM_COLUMNS; column++)
                {
                    tiles[row, column] = new NumberTile(contentManager, CalculateTileCenter(row, column),
                                                        tileSideLength, tileNumber, correctNumber, soundBank);
                    tileNumber++;
                }
            }
        }
Example #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="contentManager">the content manager</param>
 /// <param name="center">the center of the board</param>
 /// <param name="sideLength">the side length for the board</param>
 /// <param name="correctNumber">the correct number</param>
 /// <param name="soundBank">the sound bank for sound effects</param>
 public NumberBoard(ContentManager contentManager, Vector2 center, int sideLength,
                    int correctNumber, SoundBank soundBank)
 {
     // load content for the board and create draw rectangle
     LoadContent(contentManager);
     drawRectangle = new Rectangle((int)(center.X - sideLength / 2), (int)(center.Y - sideLength / 2), sideLength, sideLength);
     // calculate side length for number tiles
     tileSideLength = (sideLength - 4 * BORDER_SIZE) / 3;
     // initialize array of number tiles, (row*NUM_COLUMNS)+(column+1) lets you print the right tile
     for (int row = 0; row < NUM_ROWS; row++)
     {
         for (int column = 0; column < NUM_COLUMNS; column++)
         {
             tiles[row, column] = new NumberTile(contentManager, CalculateTileCenter(row, column),
                                                 tileSideLength, (row * NUM_COLUMNS) + (column + 1), correctNumber, soundBank);
         }
     }
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="contentManager">the content manager</param>
        /// <param name="center">the center of the board</param>
        /// <param name="sideLength">the side length for the board</param>
        /// <param name="correctNumber">the correct number</param>
        /// <param name="soundBank">the sound bank for sound effects</param>
        public NumberBoard(ContentManager contentManager, Vector2 center, int sideLength, 
            int correctNumber, SoundBank soundBank)
        {
            // load content for the board and create draw rectangle
            LoadContent(contentManager);
            drawRectangle = new Rectangle((int)center.X - sideLength / 2, (int)center.Y - sideLength / 2, sideLength, sideLength);

            // calculate side length for number tiles
            tileSideLength = (sideLength - BORDER_SIZE * (NUM_COLUMNS + 1)) / NUM_COLUMNS;

            // initialize array of number tiles
            for (int i = 0; i < NUM_ROWS; i++)
            {
                for (int j = 0; j < NUM_COLUMNS; j++)
                {
                    tiles[i, j] = new NumberTile(contentManager, CalculateTileCenter(i, j), tileSideLength, (i * 3) + j + 1, 8, null);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="contentManager">the content manager</param>
        /// <param name="center">the center of the board</param>
        /// <param name="sideLength">the side length for the board</param>
        /// <param name="correctNumber">the correct number</param>
        /// <param name="soundBank">the sound bank for sound effects</param>
        public NumberBoard(ContentManager contentManager, Vector2 center, int sideLength,
                           int correctNumber, SoundBank soundBank)
        {
            // load content for the board and create draw rectangle
            LoadContent(contentManager);
            drawRectangle = new Rectangle((int)center.X - sideLength / 2, (int)center.Y - sideLength / 2, sideLength, sideLength);

            // calculate side length for number tiles
            tileSideLength = (sideLength - BORDER_SIZE * (NUM_COLUMNS + 1)) / NUM_COLUMNS;

            // initialize array of number tiles
            for (int i = 0; i < NUM_ROWS; i++)
            {
                for (int j = 0; j < NUM_COLUMNS; j++)
                {
                    tiles[i, j] = new NumberTile(contentManager, CalculateTileCenter(i, j), tileSideLength, (i * 3) + j + 1, 8, null);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="contentManager">the content manager</param>
        /// <param name="center">the center of the board</param>
        /// <param name="sideLength">the side length for the board</param>
        /// <param name="correctNumber">the correct number</param>
        /// <param name="soundBank">the sound bank for sound effects</param>
        public NumberBoard(ContentManager contentManager, Vector2 center, int sideLength, 
            int correctNumber, SoundBank soundBank)
        {
            // load content for the board and create draw rectangle
            this.LoadContent(contentManager);
            drawRectangle = new Rectangle((int)center.X - sideLength / 2, (int)center.Y - sideLength / 2, sideLength, sideLength);

            // calculate side length for number tiles
            tileSideLength = (sideLength - 4*BORDER_SIZE) / NUM_COLUMNS;

            // initialize array of number tiles
            for (int row = 0; row < NUM_ROWS; ++row)
            {
                for (int col = 0; col < NUM_COLUMNS; ++col)
                {
                    int tileNum = 3 * row + col + 1;
                    tiles[row, col] = new NumberTile(contentManager, CalculateTileCenter(row, col), tileSideLength, tileNum, correctNumber, soundBank);
                }
            }
        }
Example #6
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="contentManager">the content manager</param>
        /// <param name="center">the center of the board</param>
        /// <param name="sideLength">the side length for the board</param>
        /// <param name="correctNumber">the correct number</param>
        /// <param name="soundBank">the sound bank for sound effects</param>
        public NumberBoard(ContentManager contentManager, Vector2 center, int sideLength,
                           int correctNumber, SoundBank soundBank)
        {
            // 16 . Write the NumberBoard constructor, which loads the content (by calling the LoadContent method you
            //wrote in the previous step), creates a new draw rectangle object,
            //and calculates the size of the number tiles
            //on the board. Be sure to include borders around the tiles using the BORDER_SIZE constant; the picture
            //below might help you generate the appropriate calculation. Don’t create the number tiles yet (Chapter 5,
            //Week 2)

            // load content for the board and create draw rectangle
            this.LoadContent(contentManager);
            drawRectangle = new Rectangle((int)center.X - sideLength / 2, (int)center.Y - sideLength / 2, sideLength, sideLength);
            // calculate side length for number tiles
            tileSideLength = (sideLength - ((NUM_COLUMNS + 1) * BORDER_SIZE)) / NUM_COLUMNS;

            // initialize array of number tiles
            // 24. In the NumberBoard constructor, add a nested for loop to initialize the NumberTile array. For now, I
            //just create all the tiles with 8 for the tile number and correct number arguments and null for the sound
            //bank argument. Note that we also have to calculate the center for each number tile to pass in to the
            //NumberTile constructor. Use the CalculateTileCenter helper method I provided to help with this
            //(Chapter 10, Week 5)
            // 28. Change the calls to the NumberTile constructor to use the actual numbers for each of the tiles. The most
            //intuitive way to do this is to use a counter variable that keeps track of the current tile number, but you can
            //also do this by calculating the current tile number based on the loop control variables for the nested for
            //loops. The board should now contain the correct number tiles when you run the game (Chapter 10, Week 5)
            int k = 1;

            for (int i = 0; i < NUM_ROWS; i++)
            {
                for (int j = 0; j < NUM_COLUMNS; j++)
                {
                    //65. In the NumberBoard constructor, change the call to the NumberTile constructor to pass the
                    //    soundBank parameter as the sound bank argument (instead of null) (Chapter 4, Week 2)

                    tiles[i, j] = new NumberTile(contentManager,
                                                 CalculateTileCenter(i, j), tileSideLength, k, correctNumber, soundBank);
                    k++;
                }
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="contentManager">the content manager</param>
        /// <param name="center">the center of the board</param>
        /// <param name="sideLength">the side length for the board</param>
        /// <param name="correctNumber">the correct number</param>
        /// <param name="soundBank">the sound bank for sound effects</param>
        public NumberBoard(ContentManager contentManager, Vector2 center, int sideLength, 
            int correctNumber, SoundBank soundBank)
        {
            // load content for the board and create draw rectangle
            LoadContent(contentManager);
            drawRectangle = new Rectangle((int)(center.X - sideLength/2), (int)(center.Y - sideLength/2), boardTexture.Width, boardTexture.Height);

            // calculate side length for number tiles
            tileSideLength = (sideLength - (BORDER_SIZE*(NUM_ROWS+1))) /NUM_ROWS;

            int n = 0;
            // initialize array of number tiles
            for (int r = 0; r < NUM_ROWS; r++)
            {
                for (int c = 0; c < NUM_COLUMNS; c++)
                {
                    n++;
                    tiles[r,c] = new NumberTile(contentManager,CalculateTileCenter(r,c),tileSideLength,n,correctNumber,null);
                }
            }
        }
Example #8
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="contentManager">the content manager</param>
 /// <param name="center">the center of the board</param>
 /// <param name="sideLength">the side length for the board</param>
 /// <param name="correctNumber">the correct number</param>
 /// <param name="soundBank">the sound bank for sound effects</param>
 public NumberBoard(ContentManager contentManager, Vector2 center, int sideLength, 
     int correctNumber, SoundBank soundBank)
 {
     // load content for the board and create draw rectangle
     LoadContent(contentManager);
     drawRectangle = new Rectangle((int)(center.X - sideLength / 2),
         (int)(center.Y - sideLength / 2), sideLength, sideLength);
     // calculate side length for number tiles
     tileSideLength = (sideLength - (NUM_COLUMNS + 1) * BORDER_SIZE) / (NUM_COLUMNS);
     // initialize array of number tiles
     int number = 1;
     for (int row = 0; row < NUM_ROWS; row++)
     {
         for (int column = 0; column < NUM_COLUMNS; column++)
         {
             tiles[row, column] = new NumberTile(contentManager,
                 CalculateTileCenter(row,column), tileSideLength, number, correctNumber,soundBank);
             number++;
         }
     }
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="contentManager">the content manager</param>
        /// <param name="center">the center of the board</param>
        /// <param name="sideLength">the side length for the board</param>
        /// <param name="correctNumber">the correct number</param>
        /// <param name="soundBank">the sound bank for sound effects</param>
        public NumberBoard(ContentManager contentManager, Vector2 center, int sideLength,
                           int correctNumber, SoundBank soundBank)
        {
            // load content for the board and create draw rectangle
            LoadContent(contentManager);
            drawRectangle = new Rectangle((int)(center.X - sideLength / 2), (int)(center.Y - sideLength / 2), boardTexture.Width, boardTexture.Height);

            // calculate side length for number tiles
            tileSideLength = (sideLength - (BORDER_SIZE * (NUM_ROWS + 1))) / NUM_ROWS;

            int n = 0;

            // initialize array of number tiles
            for (int r = 0; r < NUM_ROWS; r++)
            {
                for (int c = 0; c < NUM_COLUMNS; c++)
                {
                    n++;
                    tiles[r, c] = new NumberTile(contentManager, CalculateTileCenter(r, c), tileSideLength, n, correctNumber, null);
                }
            }
        }