static void Main(string[] args) { DrawerProvider.Drawer.InitField(); SetTimer(); currentFigure = factory.GetNewFigure(); currentFigure.Draw(); GraphicsWindow.KeyDown += GraphicsWindow_KeyDown; }
static void Main(string[] args) { Initial(); Region.Draw(); Region.DrawBorder(); Figure.Draw(); Task taskPlay = new Task(Play); taskPlay.Start(); Task taskDown = new Task(Down); taskDown.Start(); taskPlay.Wait(); taskDown.Wait(); SetHighscores(); }
/// <summary> /// обновляем экран в отдельном потоке /// </summary> void Redraw() { lock (SYNK) { grapGame.FillRectangle(Brushes.White, 0, 0, width, height); curFig.Draw(grapGame); foreach (Brick f in StaticBrickList) { f.Draw(grapGame); } grapGame.DrawImage(grid, 0, 0); } }
private static void Draw() { Console.Clear(); // draw main field field.Draw(); // next figure Console.SetCursorPosition(nextFigureX + leftMarginWidth, nextFigureY); Console.ForegroundColor = ConsoleColor.White; Console.Write("Next figure: "); nextFigure.Draw(); // draw current figure currentFigure.Draw(); }
/// <summary> /// keystroke tracking method /// </summary> public static void Play() { while (check) { ConsoleKeyInfo key = Console.ReadKey(true); Mutex.WaitOne(); if (!check) { break; } Figure figure = (Figure)Figure.Clone(); switch (key.Key) { case (ConsoleKey.RightArrow): figure.PosX += 1; break; case (ConsoleKey.LeftArrow): figure.PosX -= 1; break; case (ConsoleKey.DownArrow): figure.PosY += 1; break; case (ConsoleKey.Spacebar): figure = figure.Rotation(); break; case (ConsoleKey.Escape): check = false; break; default: break; } //rollback changes if necessary if (Region.CheckFigure(figure)) { Figure.Clear(); Figure = figure; Figure.Draw(); } Mutex.ReleaseMutex(); } }
public void Draw(Graphics graphics) { for (int i = 0; i <= gameFieldWidth; i++) { graphics.DrawLine(Pens.Black, i * cellSize, 0, i * cellSize, gameFieldHeight * cellSize); } for (int i = 0; i <= gameFieldHeight; i++) { graphics.DrawLine(Pens.Black, 0, i * cellSize, gameFieldWidth * cellSize, i * cellSize); } foreach (Point cell in busyCells) { graphics.FillRectangle(Brushes.BlueViolet, cell.X * cellSize, cell.Y * cellSize, cellSize, cellSize); } currentFigure.Draw(graphics, cellSize); nextFigure.Draw(graphics, cellSize); }
void Redraw() { Bitmap bmp = new Bitmap(boardBox.Width, boardBox.Height); Graphics g = Graphics.FromImage(bmp); for (int i = 0; i < 20; i++) { for (int j = 0; j < 10; j++) { if (gameboard[i][j] > -1) { SolidBrush brush = new SolidBrush(Figure.colors[gameboard[i][j]]); Pen pen = new Pen(brush); Rectangle rectangle = new Rectangle(j * Block.size, i * Block.size, Block.size, Block.size); g.DrawRectangle(pen, rectangle); g.FillRectangle(brush, rectangle); } } } figure.Draw(g); boardBox.Image = bmp; }