public MainLoop(int guiW, int guiH, GameOptions gameOptions, List<Player> players) { _gameOptions = gameOptions; Players = players; FieldItems = new List<Item>(); GameState = GameStates.Init; TickGameStateToStartChanged = Environment.TickCount; Item.CreateItems(); Application.AddMessageFilter(_keyMessageFilter); _panel = new MainPanel(guiW, guiH, this); _panel.Visible = true; Thread mainLoopThread = new Thread(Run); mainLoopThread.Name = "MainGameLoop"; mainLoopThread.Start(); Application.Run(_panel); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); int guiW = 1500; int guiH = 900; Rectangle screenSize = Screen.PrimaryScreen.Bounds; if (screenSize.Width < guiW) guiW = screenSize.Width - 10; if(screenSize.Height < guiH) guiH = screenSize.Height - 50; int gameScoreboardX = guiW - guiH / 5; List<Player> players = new List<Player>(); players.Add(new Player("Test1", 'a', 'd')); players.Add(new Player("Test2", 'q', 'e')); //FinalizePlayer(gameScoreboardX, guiH, start, players); GameOptions options = new GameOptions(true, true, 40, GameOptions.Host.Server, 5000, GameOptions.AllowedPause.Everyone, GameOptions.PlayerStartPositions.Random, true, null); MainLoop mainL = new MainLoop(guiW, guiH, options, players); //GUIMain view = new GUIMain(); //GUIController controller = new GUIController(view); //Controller is saved in view as reference //view.RegisterController(controller); }
private void StartLocalGame(object sender, EventArgs e) { bool items = comboBox_options_items.Items[comboBox_options_items.SelectedIndex].Equals("On"); int playerSpeed = Convert.ToInt32(comboBox_options_playerSpeed.Items[comboBox_options_playerSpeed.SelectedIndex]); int neededWins = Convert.ToInt32(comboBox_options_neededWins.Items[comboBox_options_neededWins.SelectedIndex]); bool pauseAllowed = comboBox_options_pauseAllowed.Items[comboBox_options_pauseAllowed.SelectedIndex].Equals("Yes"); bool photoFinish = comboBox_options_createWinPhoto.Items[comboBox_options_createWinPhoto.SelectedIndex].Equals("Yes"); String playerStart = (String)comboBox_options_playerStart.Items[comboBox_options_playerStart.SelectedIndex]; bool holes = true; //TODO: Add holes in GUI as option GameOptions.AllowedPause pause = pauseAllowed ? GameOptions.AllowedPause.Everyone : GameOptions.AllowedPause.Nobody; GameOptions.PlayerStartPositions startPos; if(playerStart.Equals("Line")) startPos = GameOptions.PlayerStartPositions.Line; else if(playerStart.Equals("Circle")) startPos = GameOptions.PlayerStartPositions.Circle; else startPos = GameOptions.PlayerStartPositions.Random; int guiW = 1500; int guiH = 900; Rectangle screenSize = Screen.FromControl(this).Bounds; if (screenSize.Width < guiW) guiW = screenSize.Width; if (screenSize.Height < guiH) guiH = screenSize.Height; //FinalizePlayer(startPos); GameOptions options = new GameOptions(holes, items, playerSpeed, GameOptions.Host.Server, neededWins, pause, startPos, photoFinish, null); MainLoop main = new MainLoop(guiW, guiH, options, _players); this.Visible = false; }