static void Main(string[] args) { GraphicsWindow.KeyDown += GraphicsWindow_KeyDown; Turtle.PenUp(); GraphicsWindow.BrushColor = "Red"; // выбираем красный цвет var eat = Shapes.AddRectangle(10, 10); // рисуем квадрат int x = 200; int y = 200; Shapes.Move(eat, x, y); // ставим eat в координаты x, y Random rand = new Random(); int Level = 1; Console.WriteLine("Level " + Level); while (true) { Turtle.Move(10); if ((Turtle.X >= x && Turtle.X <= x + 10) && (Turtle.Y >= y && Turtle.Y <= y + 10)) { x = rand.Next(0, GraphicsWindow.Width); y = rand.Next(0, GraphicsWindow.Height); Shapes.Move(eat, x, y); Turtle.Speed++; Level++; Console.WriteLine("Level " + Level); } if (Level == 12) { break; } Grence(Turtle.X, Turtle.Y, GraphicsWindow.Height, GraphicsWindow.Width); } PrintYouWin(); }
public void InitializeGame(GameSettings gameSettings) { Turtle turtle = new Turtle(); Position startPosition = Position.CreatePosition(gameSettings.StartPoint.X, gameSettings.StartPoint.Y); Position exitPosition = Position.CreatePosition(gameSettings.ExitPoint.X, gameSettings.ExitPoint.Y); var minePoints = gameSettings.MinePoints.Select(x => Position.CreatePosition(x.X, x.Y)).ToList(); Board board = new Board(); List <Position> boardPositionList = new List <Position>(); for (int x = 0; x < gameSettings.BoardSize.X; x++) { for (int y = 0; y < gameSettings.BoardSize.Y; y++) { var position = Position.CreatePosition(x, y); if (minePoints.Any(x => x.Equals(position))) { position.SetMine(); } boardPositionList.AddIfNotExists(position); } } board.BoardPosition = boardPositionList; board.SetStartPosition(startPosition); board.SetExitPosition(exitPosition); board.BoardPosition = boardPositionList; turtle.SetInitialPosition(startPosition, gameSettings.StartDirection); board.Turtle = turtle; Board = board; }
static void Main(string[] args) { GraphicsWindow.KeyDown += GraphicsWindow_KeyDown; Turtle.PenUp(); GraphicsWindow.BrushColor = "Red"; var eat = Shapes.AddRectangle(10, 10); int y = 200; int x = 200; Shapes.Move(eat, x, y); Random rand = new Random(); while (true) { Turtle.Move(10); if ((Turtle.X >= x - 10 && Turtle.X <= x + 10) && (Turtle.Y >= y - 10 && Turtle.Y <= y + 10)) { y = rand.Next(0, GraphicsWindow.Height); x = rand.Next(0, GraphicsWindow.Width); Shapes.Move(eat, x, y); Turtle.Speed++; } if (Turtle.X > GraphicsWindow.Width) { Turtle.X = 0; } if (Turtle.Y > GraphicsWindow.Height) { Turtle.Y = 0; } if (Turtle.X < 0) { Turtle.X = GraphicsWindow.Width; } if (Turtle.Y < 0) { Turtle.Y = GraphicsWindow.Height; } } }
static void PrintYouWin() { Turtle.X = 220; Turtle.Y = 200; Turtle.PenDown(); PrintY(); Turtle.X = 235; Turtle.Y = 200; PrintO(); Turtle.X = 270; Turtle.Y = 175; PrintU(); Turtle.X = 315; Turtle.Y = 152; PrintW(); Turtle.X = 350; Turtle.Y = 200; PrintI(); Turtle.X = 360; Turtle.Y = 200; PrintN(); Turtle.X = 399; Turtle.Y = 150; PrintVscl(); }
static void Main(string[] args) { GraphicsWindow.KeyDown += GraphicsWindow_KeyDown; Turtle.PenUp(); GraphicsWindow.BrushColor = "Red"; var eat = Shapes.AddRectangle(10, 10); int x = 200; int y = 200; Random r = new Random(); Shapes.Move(eat, x, y); while (true) { Turtle.Move(10); if (Turtle.X >= x && Turtle.X <= x + 10 && Turtle.Y >= y && Turtle.Y <= y + 10) { x = r.Next(0, GraphicsWindow.Width); y = r.Next(0, GraphicsWindow.Height); Shapes.Move(eat, x, y); Turtle.Speed++; } } }
static void Main(string[] args) { int width = GraphicsWindow.Width = 600; int height = GraphicsWindow.Height = 600; GraphicsWindow.KeyDown += GraphicsWindow_KeyDown; //убрать шлейф за черепашкой Turtle.PenUp(); GraphicsWindow.BrushColor = "red"; var eat = Shapes.AddRectangle(10, 10); int x = 200; int y = 200; Shapes.Move(eat, x, y); Random rand = new Random(); while (true) { Turtle.Move(10); if ((Turtle.X <= 0 && Turtle.Angle == 270) || (Turtle.X >= GraphicsWindow.Width && Turtle.Angle == 90) || (Turtle.Y <= 0 && Turtle.Angle == 0) || (Turtle.Y >= GraphicsWindow.Height && Turtle.Angle == 180)) { Turtle.Turn(180); } if (Turtle.X >= x && Turtle.X <= x + 10 && Turtle.Y >= y && Turtle.Y <= y + 10) { x = rand.Next(0, GraphicsWindow.Width); y = rand.Next(0, GraphicsWindow.Height); Shapes.Move(eat, x, y); Turtle.Speed++; } } }
static void Main(string[] args) { GraphicsWindow.KeyDown += GraphicsWindow_KeyDown; Console.Title = "Догони куб 3 раза"; Turtle.PenUp(); Turtle.Speed = 4; // (food) - объект который нужно поймать 3 Раза. var food = Shapes.AddRectangle(10, 10); int x = 30; int y = 40; Shapes.Move(food, x, y); Random rnd = new Random(); // Синий куб ускорения. GraphicsWindow.BrushColor = "Blue"; var speed = Shapes.AddRectangle(40, 50); int x1 = 200; int y1 = 300; Shapes.Move(speed, x1, y1); GraphicsWindow.DrawText(200, 280, "Ускорься)"); while (true) { // | //если координаты Черепахи и food пересекаются--+-- , food исчезает , затем рандомно(rnd) появляется на карте. /* | * скорость черепахи снижатся на 1, при каждом касании food'а. */ if (Turtle.X >= x && Turtle.X <= x + 20 && Turtle.Y >= y && Turtle.Y <= y + 20) { x = rnd.Next(0, GraphicsWindow.Width); y = rnd.Next(0, GraphicsWindow.Height); Shapes.Move(food, x, y); Turtle.Speed--; GraphicsWindow.BrushColor = "Red"; GraphicsWindow.DrawText(200, 260, "Осталось 2 раза =)"); if (Turtle.X >= x && Turtle.X <= x + 20 && Turtle.Y >= y && Turtle.Y <= y + 20) { GraphicsWindow.BrushColor = "Red"; GraphicsWindow.DrawText(200, 260, "Осталось 2 раза =)"); } } // Синий куб ускорения. if (Turtle.X >= x1 && Turtle.X <= x1 + 35 && Turtle.Y >= y1 && Turtle.Y <= y1 + 35) { Turtle.Speed = 7; } Turtle.Move(10); } }
static void Main() { string s; TextWindow.Show(); // запрашиваем размер еды и проверяем на допустимость do { TextWindow.WriteLine("Введите размер еды от 10 до 50px"); s = TextWindow.Read(); } while (!((int.TryParse(s, out int i)) && int.Parse(s) >= 10 && int.Parse(s) <= 50)); TextWindow.Hide(); int eatSize = int.Parse(s); Turtle.Speed = 4; Turtle.PenUp(); GraphicsWindow.CanResize = false; GraphicsWindow.BrushColor = "Red"; var eat = Shapes.AddRectangle(eatSize, eatSize); int x = 200; int y = 200; Shapes.Move(eat, x, y); Random rand = new Random(); GraphicsWindow.Title = "Погнали!"; GraphicsWindow.KeyDown += GraphicsWindow_KeyDown; while (true) { Turtle.Move(10); if (Turtle.X >= x && Turtle.X <= x + eatSize && Turtle.Y >= y && Turtle.Y <= y + eatSize) { if (Turtle.Speed < 9) { Turtle.Speed++; } if (Turtle.Speed < 9) { GraphicsWindow.Title = "Переключились на скорость: " + (Turtle.Speed - 3); } else if (Turtle.Speed == 9 && GraphicsWindow.BrushColor != "Yellow") { GraphicsWindow.Title = "Вышли на максимальную скорость!"; GraphicsWindow.BackgroundColor = "Red"; GraphicsWindow.BrushColor = "Yellow"; Shapes.Remove(eat); eat = Shapes.AddRectangle(eatSize, eatSize); } x = rand.Next(eatSize, GraphicsWindow.Width - eatSize); y = rand.Next(eatSize, GraphicsWindow.Height - eatSize); Shapes.Move(eat, x, y); } } }
static void PrintI() { Turtle.Angle = 0; Turtle.Move(25); }