Пример #1
0
        public MainForm()
        {
            InitializeComponent();

            DoubleBuffered = true;

            // just default some stuff
            currentDisplay = 1;
            twoPlayerGame  = true;

            tick = new Thread(gameTick);
            tick.Start();
            //movement.Start();
            musicthread = new Thread(playBackgroundMusic);

            gameMusic = new System.Media.SoundPlayer(Properties.Resources.Dungeon1);

            // form will contain the game and manipulate it. Again, it has to do with how forms are structured. Kinda weird.
            // Also, we are giving access to the mainForm to quoridorGame. Super weird.
            quoridorGame  = new Quoridor(this);
            quoridorBoard = quoridorGame.GameBoard;
        }
Пример #2
0
        public Game(Form form, Panel drawPanel, int windowSize, int players, int cil)
        {
            quoridor = new Quoridor(cil, players);

            this.windowSize = windowSize;
            this.form       = form;
            this.drawPanel  = drawPanel;
            this.players    = players;
            this.cil        = cil;

            int BORDER = 10;
            int width  = windowSize + 2 * BORDER + 20;
            int height = windowSize + 2 * BORDER + 50;

            form.Size           = new Size(width, height);
            drawPanel.Size      = new Size(windowSize, windowSize);
            drawPanel.Location  = new Point(BORDER, BORDER);
            drawPanel.BackColor = Color.Gray;

            boardSize  = (int)Math.Round(windowSize * cil / (cil + 4.0));
            cellSize   = (int)Math.Round(0.8 * windowSize / (cil + 4.0));
            spaceSize  = (int)Math.Round(0.2 * windowSize / (cil + 4.0));
            boardSize  = (cellSize + spaceSize) * cil;
            startCoord = (int)Math.Round((windowSize - boardSize + spaceSize) / 2.0);

            playerColors    = new SolidBrush[players];
            playerColors[0] = new SolidBrush(tileColor);
            playerColors[1] = new SolidBrush(boardColor);
            if (players == 4)
            {
                playerColors[2] = new SolidBrush(Color.FromArgb(220, 220, 80));
                playerColors[3] = new SolidBrush(Color.FromArgb(150, 50, 50));
            }
            helpPen   = new Pen(helpColor, spaceSize / 2);
            helpBrush = new SolidBrush(helpColor);
            field     = new Bitmap(windowSize, windowSize);
            DrawField(Graphics.FromImage(field));
        }