private void InitializeGame() { mineSweeper = new MineSweeper(new Point(128, 64), panel1, CellSize, new Point(0 + 1, menuStrip1.Height + 1), new Size(2, 2), 1024, toolStripTextBox1); panel1.MouseMove += mineSweeper.MouseMoving; panel1.MouseClick += mineSweeper.MouseClick; this.ResizeEnd += mineSweeper.reSize; }
private void InitializeGame(FormOptions formOp) { mineSweeper = new MineSweeper(new Point((ushort)formOp.numericUpDownSizeGameX.Value, (ushort)formOp.numericUpDownSizeGameY.Value), panel1, new Size((ushort)formOp.numericUpDown3CellSizeX.Value, (ushort)formOp.numericUpDownCellSizeY.Value), new Point(1, menuStrip1.Height + 1), new Size((ushort)formOp.numericUpDownOffsetCellX.Value, (ushort)formOp.numericUpDownOffsetCellY.Value), (ushort)formOp.numericUpDownCountBombs.Value, toolStripTextBox1); panel1.MouseMove += mineSweeper.MouseMoving; panel1.MouseClick += mineSweeper.MouseClick; this.ResizeEnd += mineSweeper.reSize; }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (MineSweeper game = new MineSweeper()) { game.Run(); } }
public void Test_4_by_4_Grid() { var map = new Board() { height = 4, width = 4 }; Coordinate[] mines = { new Coordinate() { x = 2, y = 3 }, new Coordinate() { x = 3, y = 3 }, new Coordinate() { x = 4, y = 1 }, }; var mineInstance = new MineSweeper(map, mines); var lines = mineInstance.Play(); Assert.Equal(lines[0], "|0|0|1|*|"); Assert.Equal(lines[1], "|1|2|3|2|"); Assert.Equal(lines[2], "|1|*|*|1|"); Assert.Equal(lines[3], "|1|2|2|1|"); }
static void Main(string[] args) { // Get arguments (int w, int h, int d) = ParseArguments(args); #region Initialize Game MineSweeper mine = new MineSweeper(w, h, d, colors); Console.SetWindowSize(w * 2, h + 2); mine.PrintField(); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(0, h); Console.WriteLine("Mines: " + mine.Tiles.Where(t => t.IsMine).Count()); #endregion #region Start Game mine.Player.IsPlaying = true; while (mine.Player.IsPlaying) { switch (Console.ReadKey().Key) { case ConsoleKey.UpArrow: mine.MoveCursor(-w); break; case ConsoleKey.DownArrow: mine.MoveCursor(w); break; case ConsoleKey.LeftArrow: mine.MoveCursor(-1); break; case ConsoleKey.RightArrow: mine.MoveCursor(1); break; case ConsoleKey.Z: mine.OpenTile(mine.Cursor); break; case ConsoleKey.X: mine.FlagTile(mine.Cursor); break; } mine.PrintField(); Console.SetCursorPosition(0, h); } #endregion #region End Game Console.WriteLine(mine.Player.IsDead ? "\nDead" : "\nWin"); Console.ReadLine(); #endregion }
static void Main(string[] args) { MineSweeper run = new MineSweeper(args); run.Run(); /* GameSymbol symbol =GameSymbol.Flagged;//Enum typ är en heltals typ * System.Console.WriteLine((char)symbol);*/ }
public Board(MineSweeper MineSweeper, int Height, int Width, int NumberOfMines) { this.MineSweeper = MineSweeper; this.Height = Height; this.Width = Width; this.NumberOfMines = NumberOfMines; this.Cells = new Cell[Height, Width]; this.TotalNumberOfExposedCell = 0; this.firstClick = true; }
private void startBTN_Click(object sender, EventArgs e) { if (beginnerRB.Checked) { _height = 9; _width = 9; _numberOfMines = 10; } if (intermediateRB.Checked) { _height = 16; _width = 16; _numberOfMines = 40; } if (expertRB.Checked) { _height = 16; _width = 30; _numberOfMines = 99; } _opening = true; _gameOver = false; _numberOfFlaggedFields = 0; minesRemainingLBL.Text = (_numberOfMines - _numberOfFlaggedFields).ToString(); timer1.Stop(); timeLBL.Text = "000"; int distanceFromTopOfForm = 100; pictureBox1.SetBounds( x: ClientRectangle.Width / 2 - _width * _squareWidth / 2, y: distanceFromTopOfForm + ((ClientRectangle.Height - distanceFromTopOfForm) - _height * _squareWidth) / 2, width: _width * _squareWidth, height: _height * _squareWidth); pictureBox1.Refresh(); var graphicTools = new GraphicTools(pictureBox1.CreateGraphics(), new Pen(Color.Gray, 2), new SolidBrush(Color.LightSlateGray), new SolidBrush(Color.DarkGray)); _mineSweeper = new MineSweeper(_height, _width, _numberOfMines, _squareWidth, graphicTools); _mineSweeper.Show(); }
public void Test_2_by_2_Grid() { var board = new Board() { height = 2, width = 2 }; Coordinate[] mines = { new Coordinate() { x = 1, y = 1 }, new Coordinate() { x = 2, y = 2 } }; var mineInstance = new MineSweeper(board, mines); var lines = mineInstance.Play(); Assert.Equal(lines[0], "|*|2|"); Assert.Equal(lines[1], "|2|*|"); }
public Game(int bombs, int width, int height, MineSweeper ms) { timer.Start(); fieldsUncovered = 0; level = 0; bombsCount = bombs; mapWidth = width; mapHeight = height; bombMap = new bool[mapWidth, mapHeight]; fillMapWithValue(false, bombMap); exploredMap = new bool[mapWidth, mapHeight]; fillMapWithValue(false, exploredMap); fillRandomBombs(); bombsNear = new byte[mapWidth, mapHeight]; setNearValues(); this.ms = ms; }
static void Main() { using (var game = new MineSweeper()) game.Run(); }
//Coupled meh public void setParent(MineSweeper.Form1 parent) { m_parent = parent; }
static void Main(string[] args) { MineSweeper run = new MineSweeper(args); run.Run(); }