private void MaskCreate() { int x = 0; int y = 0; for (int i = 0; i < 25; ++i) { if (i % 5 == 0 && i != 0) { x = 0; y += 50; } mask[i] = new Mask_Node(x, y); mask[i].Number = i; box[i] = new Box(i, x, y, MF); x += 50; } }
static void Main(string[] args) { Console.BufferHeight = Console.WindowHeight = 50; Console.BufferWidth = Console.WindowWidth = 60; Box[,] playField = new Box[8, 8]; ConsoleColor[] colors = { ConsoleColor.Yellow, ConsoleColor.Blue, ConsoleColor.Red, ConsoleColor.Green, ConsoleColor.Cyan, ConsoleColor.Magenta }; Random randColor = new Random(); for (int i = 0; i < playField.GetLength(0); i++) { for (int j = 0; j < playField.GetLength(1); j++) { playField[i, j] = new Box(i * 4 + 1, j * 4 + 1, colors[randColor.Next(0, colors.Length)]); playField[i, j].InitBox('\u2588'); playField[i, j].DrawBox(); } } int cursorX = 0; int cursorY = 0; while (true) { if (Console.KeyAvailable) { ConsoleKeyInfo keyPressed = Console.ReadKey(true); if (keyPressed.Key == ConsoleKey.LeftArrow) { if (cursorX > 0) { cursorX--; } } if (keyPressed.Key == ConsoleKey.RightArrow) { if (cursorX < 7) { cursorX++; } } if (keyPressed.Key == ConsoleKey.UpArrow) { if (cursorY > 0) { cursorY--; } } if (keyPressed.Key == ConsoleKey.DownArrow) { if (cursorY < 7) { cursorY++; } } if (keyPressed.Key == ConsoleKey.Spacebar) { playField[cursorX, cursorY].isSelected = true; // isSelected playField[cursorX, cursorY].DrawBox(); } else { for (int i = 0; i < playField.GetLength(0); i++) { for (int j = 0; j < playField.GetLength(1); j++) { //if (playField[i, j].isSelected) { // playField[i, j].isSelected = false; // playField[i, j].DrawBox(); //} if (playField[i, j].isCursorPosition) { playField[i, j].isCursorPosition = false; } playField[i, j].DrawBox(); } } playField[cursorX, cursorY].isCursorPosition = true; playField[cursorX, cursorY].DrawBox(); } } } }
static void Main(string[] args) { Console.BufferHeight = Console.WindowHeight = 50; Console.BufferWidth = Console.WindowWidth = 60; Box[,] playField = new Box[8, 8]; ConsoleColor[] colors = { ConsoleColor.Yellow, ConsoleColor.Blue, ConsoleColor.Red, ConsoleColor.Green, ConsoleColor.Cyan, ConsoleColor.Magenta }; Random randColor = new Random(); for (int i = 0; i < playField.GetLength(0); i++) { for (int j = 0; j < playField.GetLength(1); j++) { playField[i, j] = new Box(i * 4 + 1, j * 4 + 1, colors[randColor.Next(0, colors.Length)]); playField[i, j].InitBox('\u2588'); playField[i, j].DrawBox(); } } int cursorX = 0; int cursorY = 0; while (true) { if (Console.KeyAvailable) { ConsoleKeyInfo keyPressed = Console.ReadKey(true); if (keyPressed.Key == ConsoleKey.LeftArrow) { if (cursorX > 0) { cursorX--; } } if (keyPressed.Key == ConsoleKey.RightArrow) { if (cursorX < 7) { cursorX++; } } if (keyPressed.Key == ConsoleKey.UpArrow) { if (cursorY > 0) { cursorY--; } } if (keyPressed.Key == ConsoleKey.DownArrow) { if (cursorY < 7) { cursorY++; } } if (keyPressed.Key == ConsoleKey.Spacebar) { playField[cursorX, cursorY].isSelected = true; // isSelected playField[cursorX, cursorY].DrawBox(); } else { for (int i = 0; i < playField.GetLength(0); i++) { for (int j = 0; j < playField.GetLength(1); j++) { //if (playField[i, j].isSelected) { // playField[i, j].isSelected = false; // playField[i, j].DrawBox(); //} if (playField[i, j].isCursorPosition) { playField[i, j].isCursorPosition = false; } playField[i, j].DrawBox(); } } playField[cursorX, cursorY].isCursorPosition = true; playField[cursorX, cursorY].DrawBox(); } } } }
static void Main(string[] args) { Console.BufferHeight = Console.WindowHeight = 50; Console.BufferWidth = Console.WindowWidth = 60; Box[,] playField = new Box[8, 8]; for (int i = 0; i < playField.GetLength(0); i++) { for (int j = 0; j < playField.GetLength(1); j++) { playField[i, j] = new Box(i * 4 + 1, j * 4 + 1, ConsoleColor.Yellow); playField[i, j].InitBox('\u2588'); playField[i, j].DrawBox(); } } int cursorX = 0; int cursorY = 0; while (true) { if (Console.KeyAvailable) { ConsoleKeyInfo keyPressed = Console.ReadKey(true); if (keyPressed.Key == ConsoleKey.LeftArrow) { if (cursorX > 0) { cursorX--; } } if (keyPressed.Key == ConsoleKey.RightArrow) { if (cursorX < 7) { cursorX++; } } if (keyPressed.Key == ConsoleKey.UpArrow) { if (cursorY > 0) { cursorY--; } } if (keyPressed.Key == ConsoleKey.DownArrow) { if (cursorY < 7) { cursorY++; } } if (keyPressed.Key == ConsoleKey.Spacebar) { playField[cursorX, cursorY].boxState = 1; // isSelected playField[cursorX, cursorY].DrawBox(); } else { for (int i = 0; i < playField.GetLength(0); i++) { for (int j = 0; j < playField.GetLength(1); j++) { if (playField[i, j].boxState != 1) { playField[i, j].boxState = 0; } playField[i, j].DrawBox(); } } playField[cursorX, cursorY].boxState = 2; playField[cursorX, cursorY].DrawBox(); } } } }