public void Draw(ConsoleGraphics cg) { for (int i = 1; i < body.Count; i++) { cg.DrawRectangle(0xFFFF0000, body[i].X, body[i].Y, _cellWidth, _cellWidth, 2f); } DrawHead(cg); }
public override void OnPaint(PaintEventArgs e) { ConsoleGraphics g = e.Graphics; g.FillRectangle(ColorResources.WindowBackgroundColor, Position.X, Position.Y, Size.Width, Size.Height); g.DrawRectangle(ColorResources.WindowBorderColor, Position.X + NumericConstants.MarginUpLeft, Position.Y + NumericConstants.MarginUpLeft, Size.Width - NumericConstants.MarginRightDown, Size.Height - NumericConstants.MarginRightDown, NumericConstants.WindowBorderThikness); g.DrawString(_message, StringResources.FontName, ColorResources.WindowTextColor, Position.X + 10, Position.Y + 10, NumericConstants.FontSize); _okButton.Draw(g); }
private void ShowTab(Tab tab) { uint color = (tab.IsActive) ? Settings.ActiveColor : Settings.InactiveColor; _graphics.DrawRectangle(color, tab.CoordinateX, tab.CoordinateY, Settings.TabWidth, Settings.TabHeight); if (tab.CurrentPath == string.Empty) { DisplayDrives(color, tab); } else { tab.InitCurrentDirectory(); tab.CheckPosition(); DisplayFolderContent(color, tab); } }
public override void OnPaint(PaintEventArgs e) { ConsoleGraphics g = e.Graphics; g.FillRectangle(ColorResources.WindowBackgroundColor, Position.X, Position.Y, Size.Width, Size.Height); g.DrawRectangle(ColorResources.WindowBorderColor, Position.X + NumericConstants.MarginUpLeft, Position.Y + NumericConstants.MarginUpLeft, Size.Width - NumericConstants.MarginRightDown, Size.Height - NumericConstants.MarginRightDown, NumericConstants.WindowBorderThikness); _progressBar.Draw(g); string name = Path.GetFileName(_sourcePath); name = name.Length > 40 ? name.Substring(0, 36).Insert(36, StringResources.LongFileNameEnd) : name; string text = string.Empty; switch (_type) { case OperationType.CopyFile: text = $"Copy file:\n{name}"; break; case OperationType.MoveFile: text = $"Move file:\n{name}"; break; case OperationType.CopyDirectory: text = $"Copy directory:\n{name}"; break; case OperationType.MoveDirectory: text = $"Move directory:\n{name}"; break; } g.DrawString(text, StringResources.FontName, ColorResources.WindowTextColor, Position.X + 10, Position.Y + 20, NumericConstants.FontSize); _okButton.Draw(g); _cancelButton.Draw(g); }
public void Render(ConsoleGraphics graphics) { graphics.DrawRectangle((uint)Color, X + 4, Y + 4, 26, 26, 4); // outer rect 30x30, thickness 4px, outer margin 2px, inner margin 4 px graphics.FillRectangle((uint)Color, X + 10, Y + 10, 14, 14); // inner filled rect 14x14 px }
public void Render(ConsoleGraphics graphics) { graphics.DrawRectangle(0xFFFF0000, x, y, width, height, (float)3); }
public void Start() { snake.AddFirst(new SnakeChain(graphics)); Apple apple = new Apple(); apple.Update(this); // Game loop. while (true) { // Snake Loop int i = 0; foreach (var snakeChain in snake) { if (i == 0) { snakeChain.SetFirst(); } snakeChain.Update(this, snake); i++; } // clearing screen before painting new frame graphics.FillRectangle(0xFF000000, 0, 0, 655, 656); graphics.DrawRectangle(0xFFA9A9A9, 10, 10, 640, 640, 20); // FFA9A9A9-dark grey // Thus, we have a matrix 34x34 for a game. // But as we have a frame which has the same h/w as a snake - this reduces the playable zone to 32x32. int[] snakeHeadCoords = snake.First().GetCoords(); /// !!!!!!!!!!!!!!!!!!!!!!!!!! if ( (snakeHeadCoords[0] == 0 || snakeHeadCoords[0] >= 640) || (snakeHeadCoords[1] == 0 || snakeHeadCoords[1] >= 640) ) { GameOver("out-of-frame"); return; } // Let's paint the apple apple.Render(graphics); // Have we eaten an apple? if (IsAppleEaten(snake.First(), apple)) { applesEaten++; Console.WriteLine(" Apples eaten: " + applesEaten); SaveNextSnakeChain(); // Regenerate apple coords. apple.Update(this); } foreach (var snakeChain in snake) { snakeChain.Render(graphics); } // double buffering technique is used graphics.FlipPages(); Thread.Sleep(100); } }
public void Draw(ConsoleGraphics cg) { cg.DrawRectangle(0xFF0000FF, X, Y, 30, 30, 2f); }
public void Render(ConsoleGraphics graphics, uint color, int x, int y) { graphics.DrawRectangle(color, x, y, height, width, 2); }
private void DrawSegment(int x, int y, Color color, ConsoleGraphics graphics) { graphics.DrawRectangle((uint)color, x + 4, y + 4, 26, 26, 4); graphics.FillRectangle((uint)color, x + 10, y + 10, 14, 14); }
private void DrawSegment(ConsoleGraphics graphics) { graphics.DrawRectangle((uint)SegmentColor, X + 4, Y + 4, 26, 26, 4); graphics.FillRectangle((uint)SegmentColor, X + 10, Y + 10, 14, 14); }
private void DrawHead(ConsoleGraphics cg) { cg.DrawRectangle(0xFF00FF00, head.X, head.Y, _cellWidth, _cellWidth, 2f); }
public void Render(ConsoleGraphics graphics) { graphics.DrawRectangle(0xFFFF0000, X, Y, size, size, 1); }
public void Start() { cg.DrawRectangle(0xFF005050, 0, 0, 600, 600, 2f); currentLvl.BuildLevel(rand); AddObject(currentLvl); AddObject(food); while (true) { btnEsc.Check(); if (isExit) { break; } btnSpace.Check(); if (isPaused) { btnSpace.Check(); continue; } foreach (var i in arrowBtns) { i.Check(); } foreach (var item in drawGameObj) { item.Draw(cg); } snake.Hide(cg); RedrawStats(foodCount); if (snake[0].IntersectWith(food)) { snake.IncreaseBody(); if (foodCount++ == 1) { IncreaseLvl(++currentLvlNumber); } ChangeFoodCoord(food); food.Draw(cg); RedrawStats(foodCount); } for (int i = 1; i < snake.Length; i++) { if (snake[0].IntersectWith(snake[i])) { snake.Reset(_snakeStartCoordX, _snakeStartCoordY); ResetStats(); } } if (currentLvl.IntersectWithWalls(snake[0])) { snake.Reset(_snakeStartCoordX, _snakeStartCoordY); ResetStats(); } snake.MoveNext(); snake.Draw(cg); cg.DrawRectangle(0xFF005050, 0, 0, 600, 600, 2f); Thread.Sleep(100); cg.FlipPages(); } }