public FormMain(GameRules rules, Desk desk, Engine engine) { Application.ApplicationExit += new EventHandler(OnApplicationExit); this.rules = rules; this.desk = desk; this.engine = engine; pieces = new PictureBox[rules.getDeskSize(), rules.getDeskSize()]; playerWhiteControls = GameVar.PLAYER_HUMAN; playerBlackControls = GameVar.PLAYER_HUMAN; gameTimer = new System.Windows.Forms.Timer(); gameTimer.Interval = 1000; gameTimer.Tick += new EventHandler(gameTimer_Tick); formNewGame = new formNewGame(); formNewGame.buttonStart_Invoked += buttonNewGame_Click; formSettings = new formSettings(); formSettings.buttonSave_Clicked += buttonSettingsSave_Click; InitializeComponent(); setUpPieces(); resetGameInfo(); resetGameTimer(); aiButtonsDisable(); }
private void setUpPieces() { int piecesCnt = rules.getDeskSize(); for (int x = 0; x < piecesCnt; x++) { for (int y = 0; y < piecesCnt; y++) { pieces[x, y] = makePiece("piece" + x + '-' + y); tableDesk.Controls.Add(pieces[x, y], x, piecesCnt - 1 - y); } } }
static void Main() { //set up game and desk GameRules rules = new GameRules(); Desk desk = new Desk(rules.getDeskSize(), rules.getPiecesPerPlayer()); Engine engine = new Engine(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FormMain(rules, desk, engine)); }