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 Brick(ConsoleGraphics graphics, int brickPositionX, int brickPositionY) { this.graphics = graphics; ImgBrick = graphics.LoadImage("element_blue.png"); BrickPositionX = brickPositionX; BrickPositionY = brickPositionY; }
public StartButton(ConsoleGraphics graphics) { this.graphics = graphics; ImgStartButton = graphics.LoadImage("start_button.png"); ButtonPositionX = 100; ButtonPositionY = 100; }
public Ball(ConsoleGraphics graphics, Arcanoid arcanoid) { this.graphics = graphics; this.arcanoid = arcanoid; ImgBall = graphics.LoadImage("ballBlue.png"); BallPositionX = graphics.ClientWidth / 2 - ImgBall.Width / 2; BallPositionY = graphics.ClientWidth / 2 - ImgBall.Height * 2; }
public Target(ConsoleGraphics graphics, int x, int y, int w, int h) { X = x; Y = y; W = w; H = h; Image = graphics.LoadImage("breakout_sprites.png"); }
public Button(ConsoleGraphics graphics, int offsetX, int offsetY, int w, int h, int x, int y) { X = x; Y = y; W = w; H = h; OffsetX = offsetX; OffsetY = offsetY; Image = graphics.LoadImage("30_buttons_set.png"); }
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(); }
public static bool ContinueGame(ConsoleGraphics graphics, GameEngine engine) { var scoreCounter = engine.GetFirstObjectByType <ScoreCounter>(); graphics.DrawImagePart(graphics.LoadImage("Images/snake-gameover.jpg"), 0, 0, graphics.ClientWidth, graphics.ClientHeight, 0, 0); graphics.DrawString($"Current score:{scoreCounter.Score}", Settings.FontName, Settings.WhiteColor, 320, 450, 36); graphics.DrawString($"Best score:{scoreCounter.BestScore}", Settings.FontName, Settings.WhiteColor, 350, 520, 36); graphics.FlipPages(); while (true) { if (Input.IsKeyDown(Keys.SPACE)) { return(true); } if (Input.IsKeyDown(Keys.ESCAPE)) { return(false); } } }
public static void LoadImages(ConsoleGraphics graphics) { SnakeImage = graphics.LoadImage("images/snake.png"); TreeImage = graphics.LoadImage("images/tree.png"); }
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 SamplePlayer(ConsoleGraphics graphics) { image = graphics.LoadImage("pacman.png"); }
public CGameObject(ConsoleGraphics graphics, string img) { image = graphics.LoadImage(img); this.graphics = graphics; }
public static void Greeting(ConsoleGraphics graphics) { graphics.DrawImagePart(graphics.LoadImage("Images/snake-start.jpg"), 0, 0, graphics.ClientWidth, graphics.ClientHeight, 0, 0); graphics.FlipPages(); Console.ReadLine(); }