示例#1
0
        private void UpdateScreen()
        {
            if (!_isText)
            {
                Image[,] images        = _analyzer.DisplayGrid();
                PictureBox[,] evidence = new PictureBox[images.GetLength(0), images.GetLength(1)];
                PlayArea.Controls.Clear(); //clear old boxes

                for (int i = 0; i < evidence.GetLength(0); i++)
                {
                    for (int j = 0; j < evidence.GetLength(1); j++)
                    {
                        evidence[i, j]             = new PictureBox();
                        evidence[i, j].Location    = new Point(j * 50 + 1, i * 50 + 1);//setting x and y points
                        evidence[i, j].Size        = new Size(50, 50);
                        evidence[i, j].BorderStyle = BorderStyle.FixedSingle;
                        evidence[i, j].Image       = images[i, j];
                        PlayArea.Controls.Add(evidence[i, j]);
                    }
                }
            }
            else if (_isText)
            {
                PlayArea.Controls.Clear();//clear old boxes/text

                Label PlayLabel = new Label();
                PlayLabel.Text = _analyzer.PrintGrid();
                PlayLabel.Font = PlayText.Font;
                PlayLabel.Dock = DockStyle.Fill;
                PlayArea.Controls.Add(PlayLabel);
            }
        }
示例#2
0
        public frmGameWindow(Map_Stuff.MapBuilderInterface GameMap)
        {
            InitializeComponent();

            //Build the game display, a 2dimensional array the same size as the game map
            PictureBox[,] GameDisplay = new PictureBox[GameMap.GetWidth(), GameMap.GetHeight()];

            for (int i = 0; i < GameDisplay.GetLength(0); i++)
            {
                for (int j = 0; j < GameDisplay.GetLength(1); j++)
                {
                    GameDisplay[i, j]          = new PictureBox();
                    GameDisplay[i, j].Location = new Point(i * 40, j * 40);
                    GameDisplay[i, j].Size     = new Size(40, 40);

                    this.Controls.Add(GameDisplay[i, j]);
                }
            }

            CurrentTerrain = new Simple_Game.Map(GameMap, GameDisplay, imglstTileImages);
        }
示例#3
0
        /// <summary>
        /// Returns a 2D PictureBox array with each element having default values set.
        /// </summary>
        /// <param name="rows"></param>
        /// <param name="columns"></param>
        /// <returns></returns>
        private PictureBox[,] GenerateGameBoard(int rows, int columns)
        {
            // Starting location for the top left PictureBox.
            int startingX = 200;
            int startingY = 90;

            PictureBox[,] filledBoard = new PictureBox[rows, columns];

            for (int r = 0; r < filledBoard.GetLength(0); r++)
            {
                for (int c = 0; c < filledBoard.GetLength(1); c++)
                {
                    PictureBox emptyBox = DefaultEmptyPicturebox(r, c, new Point(startingX, startingY));

                    filledBoard[r, c] = emptyBox;
                    startingX        += 38; // Move Right
                }
                startingX  = 200;           // Original X position
                startingY += 38;            // Move Down
            }

            return(filledBoard);
        }