public StartButton(ConsoleGraphics graphics) { this.graphics = graphics; ImgStartButton = graphics.LoadImage("start_button.png"); ButtonPositionX = 100; ButtonPositionY = 100; }
public Brick(ConsoleGraphics graphics, int brickPositionX, int brickPositionY) { this.graphics = graphics; ImgBrick = graphics.LoadImage("element_blue.png"); BrickPositionX = brickPositionX; BrickPositionY = brickPositionY; }
public void PlayGame() { while (true) { ConsoleGraphics graphics = new ConsoleGraphics(); Console.CursorVisible = false; Button start = new Button(graphics, 0, 0, 200, 50, graphics.ClientWidth / 2 - 100, graphics.ClientHeight / 2 - 150); Button exit = new Button(graphics, 200, 270, 190, 50, graphics.ClientWidth / 2 - 95, graphics.ClientHeight / 2); while (!exit.Push()) { start.Render(graphics); exit.Render(graphics); if (start.Push() == true || exit.Push() == true) { break; } graphics.FlipPages(); System.Threading.Thread.Sleep(10); } if (exit.Push() == true) { break; } Level level = new Level(); level.Level_1(graphics); } }
public void Render(ConsoleGraphics graphics) { foreach (SnakeSegment c in _snake) { graphics.FillRectangle(Settings.SnakeColor, c.X + 1, c.Y + 1, Settings.SizeCell - 1, Settings.SizeCell - 1); } }
public static void StartGame(ConsoleGraphics graphics) { Console.Clear(); GameEngine engine = new SampleGameEngine(graphics); engine.Start(); }
// точка начала -x,y, z - сторона public Star(ConsoleGraphics graphics, int x, int y, int side) { this.graphics = graphics; this.x = x; this.y = y; this.side = side; }
public void Render(ConsoleGraphics graphics) { if (!start) { MenuPage(graphics); } else if (ball.y > (boat.y + boat.y + boat.h) / 2) { message = "You Lose. Your points: " + points.ToString(); MenuPage(graphics); } else if (bricks.Count == 0) { message = "You Win. Your points: " + points.ToString(); MenuPage(graphics); } else { foreach (var e in bricks) { e.Render(graphics); } ball.Render(graphics); boat.Render(graphics); } }
public static void Run() { while (true) { ConsoleGraphics graphics = new ConsoleGraphics(); GameEngine engine = new ArkanoidGameEngine(graphics); engine.Start(); graphics.DrawString("FOR NEW GAME PRESS SPASE\n FOR EXIT GAME PRESS ESC", "Arial", 0xFF000080, 460, 450, 20); graphics.DrawString("(FOR RESET BEST SCORS PRESS (R)", "Arial", 0xFF000080, 530, 550, 10); graphics.FlipPages(); while (Console.KeyAvailable) { Console.ReadKey(); } ConsoleKeyInfo keyInfo = Console.ReadKey(); ConsoleKey key = keyInfo.Key; if (key == ConsoleKey.Escape) { break; } if (key == ConsoleKey.R) { Scors.WriteInFileBestScors(0); Scors.SetBestScors(0); } } }
public void Render(ConsoleGraphics graphics) { for (int i = 0; i < _cells.Length; i++) { graphics.FillRectangle(_cells[i].Color, _cells[i].X, _cells[i].Y, FieldSize.width, FieldSize.height); } }
void DarwSnake(ConsoleGraphics graphics) { foreach (var segment in body) { segment.Render(graphics); } }
public void Render(ConsoleGraphics graphics) { foreach (var item in field) { item.Render(graphics); } }
public Engine(ConsoleGraphics consoleGraphics) { this.consoleGraphics = consoleGraphics; this.canvas = new Rectangle(0, 0, consoleGraphics.ClientWidth, consoleGraphics.ClientHeight, (uint)Colors.Red); GameReset(); SetTimer(); }
public void Render(ConsoleGraphics graphics) { foreach (var item in snake) { item.Render(g); } }
public Superman(ConsoleGraphics gr, Size gameSize) { this.gr = gr; location = new Point(gr.CONSOLE_WIDTH / 2, gr.CONSOLE_HEIGHT / 2); this.gameSize = gameSize; this.supermanSize = new Size(superman[0].Length, superman.GetLength(0)); }
static void Main(string[] args) { Console.SetWindowPosition(0, 0); Console.WindowHeight = 34; Console.WindowWidth = 48; Console.SetBufferSize(Console.WindowWidth, Console.WindowHeight); Console.BackgroundColor = ConsoleColor.White; Console.CursorVisible = false; Console.Clear(); ConsoleGraphics graphics = new ConsoleGraphics(); //Console.WriteLine(graphics.ClientHeight); //Console.WriteLine(graphics.ClientWidth); GameEngine engine = new TetrisGameEngine(graphics); Field Field = new Field(graphics); Field.FillField(graphics); engine.Start(Field, engine); graphics.FillRectangle(0xFFFFFFFF, 0, 0, graphics.ClientWidth, graphics.ClientHeight); graphics.FlipPages(); Console.WriteLine("game is over"); Console.ReadLine(); Console.WriteLine("Play again? "); Console.WriteLine(" if yes press any key"); Console.WriteLine("if no press escape"); var key = Console.ReadKey(); if (key.Key != ConsoleKey.Escape) { Main(null); } }
public Board(ConsoleGraphics graphics, string img) : base(graphics, img) { X = 600; Y = 745; H = 25; W = 116; }
// точка начала -x,y, z - сторона public Square(ConsoleGraphics graphics, int x, int y, int side) // передаем в конструктор обьект graphics чтобы пользоваться методами ConsoleGraphics { this.graphics = graphics; this.x = x; this.y = y; this.side = side; }
public void Render(ConsoleGraphics cg) { foreach (MenuItem item in items) { item.Draw(cg); } }
public Arcanoid(ConsoleGraphics graphics) { this.graphics = graphics; ImgArcanoid = graphics.LoadImage("paddleBlu.png"); PlatformPositionX = graphics.ClientWidth / 2 - ImgArcanoid.Width / 2; PlatformPositionY = graphics.ClientHeight - ImgArcanoid.Height; }
public Blocks(int X, int Y, ConsoleGraphics graphics, string img) : base(graphics, img) { this.X = X; this.Y = Y; H = 30; W = 30; }
public SampleGameEngine(ConsoleGraphics graphics) : base(graphics) { //AddObject(new SamplePlayer(graphics)); player = new Player(graphics); AddObject(player); }
public Highscore(ConsoleGraphics gr, Spielmodus spielmodus) { this.gr = gr; this.spielmodus = spielmodus; switch (this.spielmodus) { case Spielmodus.Normal: chosenHighscore = fileHighscoreNormal; break; case Spielmodus.Endlos: chosenHighscore = fileHighscoreEndlos; break; case Spielmodus.Hardcore: chosenHighscore = fileHighscoreHardcore; break; } if (!File.Exists(chosenHighscore)) { File.Create(chosenHighscore); } }
public static void ShowHighscore(ConsoleGraphics graphics) { graphics.FillRectangle(0xFFFFFFFF, 0, 0, graphics.ClientWidth, graphics.ClientHeight); Button Back = new Button("Back", 0, 0, 120, 20, 0xFFFF00FF, graphics); Back.AddToBoard(graphics); graphics.DrawString("Name", "Arial", 0xFFFF00FF, 15, 20); graphics.DrawString("Score", "Arial", 0xFFFF00FF, 120, 20); string[] lines = System.IO.File.ReadAllLines("Highscore.txt"); for (int i = 0; i < lines.Length; i++) { string[] result = lines[i].Split(';'); graphics.DrawString(result[0], "Arial", 0xFFFF00FF, 15, 20 * (i + 2)); graphics.DrawString(result[1], "Arial", 0xFFFF00FF, 120, 20 * (i + 2)); } graphics.FlipPages(); while (true) { if (Input.IsMouseLeftButtonDown) { if (Back.IsCollision(Input.MouseX, Input.MouseY)) { return; break; } } } }
public override void OnPaint(PaintEventArgs e) { ConsoleGraphics g = e.Graphics; var items = _items; g.FillRectangle(ColorResources.ListViewBackgroundColor, Position.X, Position.Y, Size.Width, Size.Height); int lastIndex = _visibleItemsFirstIndex + _visibleItemsCount > items.Count ? items.Count : _visibleItemsFirstIndex + _visibleItemsCount; for (int i = _visibleItemsFirstIndex; i < lastIndex; i++) { items[i].Draw(g, new Point(_itemsStartPosition.X + NumericConstants.MarginUpLeft, _itemsStartPosition.Y + (i - _visibleItemsFirstIndex) * NumericConstants.ListViewItemHeight + NumericConstants.MarginUpLeft), new Size(NumericConstants.ListViewItemHeight, Size.Width - NumericConstants.MarginRightDown)); } g.DrawLine(ColorResources.AppBackground, Position.X, Position.Y + NumericConstants.ListViewItemHeight, Position.X + Size.Width, Position.Y + NumericConstants.ListViewItemHeight, NumericConstants.WindowBorderThikness); g.DrawLine(ColorResources.AppBackground, Position.X, Size.Height - NumericConstants.ListViewItemHeight, Position.X + Size.Width, Size.Height - NumericConstants.ListViewItemHeight, NumericConstants.WindowBorderThikness); g.DrawString(_drawingPath, StringResources.FontName, ColorResources.ListItemTextColor, Position.X, Position.Y, NumericConstants.FontSize); g.DrawString($"{SelectedIndex + 1}/{this._items.Count}", StringResources.FontName, ColorResources.ListItemTextColor, Position.X + 22, Size.Height - NumericConstants.ListViewItemHeight + 3, NumericConstants.FontSize); }
public void Render(ConsoleGraphics graphics) { for (int i = 0; i < lines.Length; i++) { lines[i].Render(graphics); } }
public Controller() { _graphics = new ConsoleGraphics(); _userActionListener = new UserActionListener(); _modularWindow = new ModularWindow(_graphics); _fileSystemService = new FileSystemService(); _tabs = new List <Tab>() { new Tab(Settings.LeftWindowCoordinateX, Settings.WindowCoordinateY, _userActionListener, _fileSystemService) { IsActive = true }, new Tab(Settings.RigthWindowCoordinateX, Settings.WindowCoordinateY, _userActionListener, _fileSystemService) }; _systemItemView = new SystemItemView(_graphics); _tabView = new TabView(_tabs, _graphics, _systemItemView); _hints = new Hints(_graphics); _userActionListener.TabSwitching += SelectNextTab; _userActionListener.PropertyRequest += GetProperty; _userActionListener.FileServiceOperation += OperationEventHandler; _userActionListener.CompletionOfWork += () => Exit = true; }
protected virtual void DrawTitle(ConsoleGraphics g) { var maxCharacters = g.Width - 2 - ReserveRightAreaTitle; var text = (this.Title = this.Title == null ? string.Empty : this.Title).TruncWords(maxCharacters); var trailing = ""; switch (this.TitlePosition) { case EnumTitlePosition.Right: for (var i = 0; i < maxCharacters - text.Length; i++) { trailing += ' '; } break; case EnumTitlePosition.Center: var leftAdd = (maxCharacters - text.Length) / 2; for (var i = 0; i < leftAdd; i++) { trailing += ' '; } break; } text = $"{trailing}{text}"; g.DrawText(1, 0, text, this.ForegroundColor); }
public static void Render(ConsoleGraphics consoleGraphics, CustomList.List <SnekePartMove> snake) { for (int i = 0; i < snake.Count; i++) { snake[i].Render(consoleGraphics); } }
public SnekePartMove(uint color, int x, int y, ConsoleGraphics graphics) { _graphics = graphics; _color = color; X = x; Y = y; }
static void Main(string[] args) { Console.WindowWidth = 60; Console.WindowHeight = 30; Console.SetBufferSize(Console.WindowWidth, Console.WindowHeight); Console.BackgroundColor = ConsoleColor.Black; Console.CursorVisible = false; Console.Clear(); ConsoleGraphics graphics = new ConsoleGraphics(); GameScore game = new GameScore(); bool restart = false; while (true) { if (game.GameIsOn) { StartGame(graphics, game); } if (!restart) { Restart(graphics, game); if (Input.IsKeyDown(Keys.SPACE)) { restart = true; game.GameIsOn = true; } } graphics.FlipPages(); Thread.Sleep(80); } }