static void Main(string[] args) { Console.SetBufferSize(80, 25); Figure H1 = new HorizontalLine(0, 79, 0, '+'); H1.Draw(); Figure H2 = new HorizontalLine(0, 79, 23, '+'); H2.Draw(); Figure V1 = new VerticalLine(0, 0, 23, '+'); V1.Draw(); Figure V2 = new VerticalLine(79, 0, 23, '+'); V2.Draw(); WallsCreator W1 = new WallsCreator(2, 10, Direction.LEFT, 79, 23); W1.Draw(); WallsCreator W2 = new WallsCreator(2, 10, Direction.DOWN, 79, 23); W2.Draw(); Point p1 = new Point(4, 8, '#'); Snake s1 = new Snake(p1, 7, Direction.RIGHT); s1.Draw(); FoodCreator foodCr = new FoodCreator(79, 23, '@'); Point food = foodCr.Create(); food.Print(ConsoleColor.Red); while (true) { if (s1.eat(food)) { food = foodCr.Create(); food.Print(ConsoleColor.Red); } if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); s1.HandControl(key); } s1.Move(); Thread.Sleep(150); } }
static void Main(string[] args) { Point localPoint; localPoint.X = 10; localPoint.Y = 10; var array = new Point[10]; array[0].X = 10; staticPoint.X = 10; var instance = new Program(); instance.dynamicPoint.X = 10; Point point = new Point() { X = 10, Y = 30 }; Console.WriteLine(point.X); point = new Point(10, 20); point.Print(); staticPoint.Print(); //X[] xs = new X[10]; //xs[0].A = 1; //только структура //xs[0] = new X(); //класс или структура X x; x = new X(); //класс или структура x.arr = 5; //только структура }
public void Move() { Point p1 = new Point(); p1 = GetNextPoint(); pList.Add(p1); p1.Print(); pList.ElementAt(0).Clear(); pList.RemoveAt(0); }
internal bool eat(Point food) { bool eat0 = false; if (GetNextPoint().isMeat(food)) { Point p1 = new Point(); p1 = GetNextPoint(); pList.Add(p1); p1.Print(); eat0 = true; } return(eat0); }