public void ShowCards() // Вывод имеющихся карт { int i = 0; ConsoleGraphics.DrawString(Name, font10, Brushes.White, 20, Position * 90); foreach (Karta Card in Cards.ToArray().Reverse()) { ConsoleGraphics.DrawImage(Card.karta, i++ *13, 15 + Position * 90, WidthCard, HeightCard); } }
void ShowCards() // Вывод карт игроков и на столе { ConsoleGraphics.Clear(Color.Black); foreach (var player in players) { player.ShowCards(); } for (int i = 0; i < cards_on_the_table.Count; i++) { ConsoleGraphics.DrawImage(cards_on_the_table[i].karta, 540, 15 + players[i].Position * 90, WidthCard, HeightCard); } }
private void DrawTitileScreen() { bool proceed = false; while (!proceed) { canvas.Render(consoleGraphics); consoleGraphics.DrawString("TETЯIS", "Times New Roman", (uint)Colors.Yellow, 150, 80, 100); consoleGraphics.DrawString(" PRESS SPACE TO START", "Consolas", (uint)Colors.Yellow, 230, 650, 20); consoleGraphics.DrawString("LOGO BY FREEPNG.RU EDUCATIONAL PROJECT ©2019", "Consolas", (uint)Colors.Yellow, 225, 750, 10); ConsoleImage logo = consoleGraphics.LoadImage(@"logo.bmp"); consoleGraphics.DrawImage(logo, 255, 300); consoleGraphics.FlipPages(); if (Input.IsKeyDown(Keys.SPACE)) { proceed = true; } } Utility.SleepLong(); }
void IGameObject.Render(ConsoleGraphics graphics) { graphics.DrawImage(ImgBrick, BrickPositionX, BrickPositionY); }
void IGameObject.Render(ConsoleGraphics graphics) { graphics.DrawImage(ImgArcanoid, PlatformPositionX, PlatformPositionY); }
static void Main(string[] args) { Random x_Random_to_apple = new Random(); Random y_Random_to_apple = new Random(); int[] x_apple = new int[100000]; int[] y_apple = new int[100000]; for (int i = 0; i < 100; i++) { x_apple[i] = 10 * x_Random_to_apple.Next(2, 50); y_apple[i] = 10 * y_Random_to_apple.Next(2, 30); } int lenght, X_head, Y_head; const int delay = 100; int i_to_apple; int speed = 500; bool crashed = false; bool quit = false; bool retry = false; Console.CursorVisible = false; ConsoleKeyInfo presskey; Console.WindowHeight = 84; Console.WindowWidth = 84; Direction curDirection = Direction.Up; while (!quit) { Console.Clear(); Console.Title = "Используй 'a', 's', 'd', 'w'. Для выхода нажми 'q' "; X_head = 100; Y_head = 100; i_to_apple = 0; lenght = 1; crashed = false; quit = false; ConsoleGraphics graphics = new ConsoleGraphics(); GameBox box = new GameBox(10, 10, 300, 500); SnakeBody[] body = new SnakeBody[1]; int[] x_body_mass = new int[1]; int[] y_body_mass = new int[1]; x_body_mass[0] = 100; y_body_mass[0] = 110; Apple apple = new Apple(x_apple[i_to_apple], y_apple[i_to_apple]); var imgApple = graphics.LoadImage("40320.jpg"); SnakeHead head = new SnakeHead(X_head, Y_head); // Ждать нажатия клавиши while (!Console.KeyAvailable) { Thread.Sleep(100); } // изменение направления presskey = Console.ReadKey(true); switch (presskey.KeyChar) { case 'w': curDirection = Direction.Up; break; case 's': curDirection = Direction.Down; break; case 'a': curDirection = Direction.Left; break; case 'd': curDirection = Direction.Right; break; case 'q': quit = true; break; } // Игра DateTime nextCheck = DateTime.Now.AddMilliseconds(delay); while (!quit && !crashed) { Console.Title = "Length: " + lenght.ToString();//увеличивает наш счетчик длинны if (X_head < 10 || Y_head < 10 || X_head > 500 || Y_head > 300) { crashed = true; } if ((X_head == x_apple[i_to_apple]) && (Y_head == y_apple[i_to_apple])) { lenght++; if (lenght % 2 == 0 && speed != 0) { speed -= 50; } i_to_apple++; } while (nextCheck > DateTime.Now) { if (Console.KeyAvailable) { presskey = Console.ReadKey(true); switch (presskey.KeyChar) { case 'w': if (curDirection != Direction.Down) { curDirection = Direction.Up; } break; case 's': if (curDirection != Direction.Up) { curDirection = Direction.Down; } break; case 'a': if (curDirection != Direction.Right) { curDirection = Direction.Left; } break; case 'd': if (curDirection != Direction.Left) { curDirection = Direction.Right; } break; case 'q': quit = true; break; } } } Thread.Sleep(speed); graphics.FillRectangle(0xFF000000, 0, 0, graphics.ClientHeight, graphics.ClientWidth); box.Render(graphics, 0xFFFFFFFF, 10, 10); head.Render(graphics, 0xFFFF0000, X_head, Y_head); graphics.DrawImage(imgApple, x_apple[i_to_apple], y_apple[i_to_apple]); if (!quit) { switch (curDirection) { case Direction.Up: x_body_mass[body.Length - 1] = X_head; y_body_mass[body.Length - 1] = Y_head; head.Up(ref Y_head); break; case Direction.Down: x_body_mass[body.Length - 1] = X_head; y_body_mass[body.Length - 1] = Y_head; head.Down(ref Y_head); break; case Direction.Left: x_body_mass[body.Length - 1] = X_head; y_body_mass[body.Length - 1] = Y_head; head.Left(ref X_head); break; case Direction.Right: x_body_mass[body.Length - 1] = X_head; y_body_mass[body.Length - 1] = Y_head; head.Right(ref X_head); break; } nextCheck = DateTime.Now.AddMilliseconds(delay); } } if (crashed) { Console.Title = "*** Crashed! *** Length: " + lenght.ToString() + " Hit 'q' to quit, or 'r' to retry!"; while (!quit && !retry) { if (Console.KeyAvailable) { presskey = Console.ReadKey(true); switch (presskey.KeyChar) { case 'q': quit = true; break; case 'r': retry = true; break; } } } } } }
public void Render(ConsoleGraphics graphics) { graphics.DrawImage(image, x, y); }