public void TestTurtleMove(Direction heading, int expectedX, int expectedY) { turtle.Move(); var expectedPoint = new Coordinate(expectedX, expectedY); Assert.AreEqual(expectedPoint.X, turtle.TurtlePosition.X); Assert.AreEqual(expectedPoint.Y, turtle.TurtlePosition.Y); }
public void Move_IfDirectionIsEast_DecreaseX() { _turtle.Direction = App.Enums.Direction.East; _turtle.Move(); Assert.That(_turtle.X == TurtlePosX - 1); }
public void MovesWhenMovePossible() { var turtle = new Turtle(new Coordinate(3, 2), Direction.S); turtle.Move(movePossible); turtle.Move(movePossible); Assert.AreEqual(new Coordinate(5, 2), turtle.Position); }
public void CanMoveTurtle() { turtle.posX = 3; turtle.posY = 1; turtle.facingPos = Coordinates.North; turtle.Move(); turtle.Move(); Assert.AreEqual(turtle.posX, 1); }
public void Turtle_PlacedMovedAndTurned_ReportsCorrectPosition() { var Turtle = new Turtle(); Turtle.Place(1, 2, Facing.East); Turtle.Move(); Turtle.Move(); Turtle.Left(); Turtle.Move(); Assert.AreEqual("3,3,NORTH", Turtle.Report()); }
public void TurtleMove_TurtleMovesInBoard() { Board gameBoard = TestHelper.GetEmptyBoard(1, 3); Turtle turtle = new Turtle(Direction.North, gameBoard); gameBoard.AddGameObject(0, 2, turtle); turtle.Move(); Assert.True(new Coordinate(0, 1).IsSame(turtle.GetCurrentCoordinate())); turtle.Move(); Assert.True(new Coordinate(0, 0).IsSame(turtle.GetCurrentCoordinate())); }
static void Main(string[] args) { int ang1 = 90; int ang2 = 60; int ang3 = 120; int ang4 = 270; int ang5 = 180; int len1 = 200; int len2 = 50; int len3 = 100; Turtle.Speed = 5; Turtle.Turn(ang5); Turtle.PenUp(); Turtle.Move(len1); Turtle.Turn(ang4); Turtle.PenDown(); Turtle.Move(len1); Turtle.Turn(ang1); Turtle.Move(len1); Turtle.Turn(ang1); Turtle.Move(len1); Turtle.Turn(ang2); Turtle.Move(len2); }
static void Main(string[] args) { //Pila(); //Six(); //Moloko(); GraphicsWindow.KeyDown += GraphicsWindow_KeyDown; Turtle.PenUp(); int moveFoodX = 150; int moveFoodY = 150; GraphicsWindow.BrushColor = "Red"; var food = Shapes.AddRectangle(12, 12); Shapes.Move(food, moveFoodX, moveFoodY); Random random = new Random(); while (true) { if (Turtle.X - moveFoodX < 15 && Turtle.Y - moveFoodY < 15 && moveFoodX - Turtle.X < 15 && moveFoodY - Turtle.Y < 15) { moveFoodX = random.Next(0, GraphicsWindow.Width); moveFoodY = random.Next(0, GraphicsWindow.Height); Shapes.Move(food, moveFoodX, moveFoodY); Turtle.Speed++; } Turtle.Move(10); } }
static void Main(string[] args) { var len = 30; Turtle.Move(len); Turtle.Turn(90); Turtle.Move(len); Turtle.Turn(90); Turtle.Move(len); Turtle.Turn(90); Turtle.Move(len); Turtle.PenUp(); Turtle.Move(len); Turtle.Turn(90); Turtle.Move(len * 2); Turtle.PenDown(); Turtle.Turn(90); Turtle.Move(len * 3); Turtle.Turn(90); Turtle.Move(len * 3); Turtle.Turn(90); Turtle.Move(len * 3); Turtle.Turn(90); Turtle.Move(len * 3); Turtle.Turn(30); Turtle.Move(len * 3); Turtle.Turn(120); Turtle.Move(len * 3); }
static void Main(string[] args) { var len = 100; Turtle.Speed = 8; Turtle.Turn(90); Turtle.Move(len); Turtle.TurnRight(); Turtle.Move(len); Turtle.TurnRight(); Turtle.Move(len); Turtle.TurnRight(); Turtle.Move(len); Turtle.Turn(46); Turtle.Move(71.98); Turtle.Turn(89.6); Turtle.Move(71); Turtle.PenUp(); Turtle.Turn(89); Turtle.Move(40); Turtle.Turn(-45); Turtle.PenDown(); Turtle.Move(40); Turtle.TurnRight(); Turtle.Move(40); Turtle.TurnRight(); Turtle.Move(40); Turtle.TurnRight(); Turtle.Move(40); Turtle.PenUp(); Turtle.Move(500); }
static void Main(string[] args) { Random rand = new Random(); // Не оставлять след Turtle.PenUp(); // Добавление еды GraphicsWindow.BrushColor = "Green"; var food = Shapes.AddRectangle(10, 10); int foodX = 200; int foodY = 200; Shapes.Move(food, foodX, foodY); while (true) { GraphicsWindow.KeyDown += GraphicsWindow_KeyDown; Turtle.Move(10); if ((Turtle.X >= foodX - 10 && Turtle.X <= foodX + 10) && (Turtle.Y >= foodY - 10 && Turtle.Y <= foodY + 10)) { foodX = rand.Next(0, GraphicsWindow.Width); foodY = rand.Next(0, GraphicsWindow.Height); Shapes.Move(food, foodX, foodY); Turtle.Speed++; } } }
public void DrawWindw() { try { if (2 * Wall < 3) { throw new Exception("Dividing by zero Exception"); } else { Turtle.PenUp(); Turtle.Move(2 * Wall / 3); DrawSide(Wall / 3, 90); Turtle.PenDown(); Turtle.Move(Wall / 3); for (int i = 0; i < 4; i++) { DrawSide(Wall / 3, 90); } } } catch (Exception e) { Console.WriteLine(e.Message); } }
static void Main(string[] args) { Console.WriteLine("click Enter to start"); Console.ReadLine(); GraphicsWindow.KeyDown += GraphicsWindow_KeyDown; Turtle.PenUp(); GraphicsWindow.BrushColor = "Blue"; 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 >= x && Turtle.X <= x + 12 && Turtle.Y >= y && Turtle.Y <= y + 12) { 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; Turtle.PenUp(); GraphicsWindow.BrushColor = "Red"; var eat = Shapes.AddRectangle(10, 10); var eatPosX = 200; var eatPosY = 200; Random rand = new Random(); Shapes.Move(eat, eatPosX, eatPosY); while (true) { Turtle.Move(10); if (Turtle.X >= eatPosX && Turtle.X <= eatPosX + 10 && Turtle.Y >= eatPosY && Turtle.Y <= eatPosY + 10) { eatPosX = rand.Next(0, GraphicsWindow.Width); eatPosY = rand.Next(0, GraphicsWindow.Height); Shapes.Move(eat, eatPosX, eatPosY); Turtle.Speed += 1; } } }
static void Main(string[] args) { Turtle.Speed = 9; for (int i = 0; i < Cycles; i++) { Turtle.Move(Dynamic); Turtle.TurnRight(); Turtle.Move(Dynamic); Turtle.TurnRight(); Turtle.Move(Dynamic); Turtle.TurnLeft(); Turtle.Move(Dynamic); Turtle.TurnLeft(); } Turtle.Turn(180); Turtle.Move(Dynamic); Turtle.TurnRight(); Turtle.Move(Dynamic * 11); for (int i = 0; i < 7; i++) { Turtle.Turn(45); Turtle.Move(Dynamic * 2.5); } }
public static void doubleTurnLeft() { Turtle.Move(25); Turtle.TurnLeft(); Turtle.Move(25); Turtle.TurnLeft(); }
static void Main(String[] args) { var len = 100; Turtle.Speed = 8; // Рисуем тело домика Turtle.Turn(90); Square(len); // Рисуем крышу Turtle.Turn(-60); Turtle.Move(len); Turtle.Turn(120); Turtle.Move(len); Turtle.Turn(30); // Рисуем окошко Turtle.PenUp(); Turtle.Move(2 * len / 3); Turtle.Turn(90); Turtle.Move(len / 3); Turtle.PenDown(); Square(len / 3); }
public static void WriteG(int longLine, int shortLine) { Turtle.Angle = 0; Turtle.Move(longLine); Turtle.TurnRight(); Turtle.Move(shortLine); }
static void Main(string[] args) { GraphicsWindow.Title = "Turtle eat"; GraphicsWindow.Width = 800; GraphicsWindow.Height = 700; GraphicsWindow.KeyDown += GraphicsWindow_KeyDown; Turtle.PenUp(); GraphicsWindow.BrushColor = "Red"; var eat = Shapes.AddRectangle(10, 10); var xx = 100; var yy = 200; Shapes.Move(eat, xx, yy); Random rand = new Random(); while (true) { Turtle.Move(10); if (Turtle.X <= (xx + 15) && Turtle.X > (xx - 10) && Turtle.Y <= (yy + 15) && Turtle.Y > (yy - 10)) { xx = rand.Next(GraphicsWindow.Width); yy = rand.Next(GraphicsWindow.Height); Shapes.Move(eat, xx, yy); Turtle.Speed++; } } }
static void Main(string[] args) { GraphicsWindow.KeyDown += GraphicsWindow_KeyDown; Turtle.PenUp(); var eat = Shapes.AddEllipse(10, 10); int x = 200; int y = 200; Shapes.Move(eat, x, y); Random rand = new Random(); while (true) { Turtle.Move(5); if ((Turtle.X >= x && Turtle.X <= x + 10) && (Turtle.Y >= y && Turtle.Y <= y + 10)) { x = rand.Next(10, GraphicsWindow.Width); y = rand.Next(10, GraphicsWindow.Height); Shapes.Move(eat, x, y); Turtle.Speed++; } } }
static void Main(string[] args) { int x = 200; int y = 200; GraphicsWindow.BrushColor = "Red"; var eat = Shapes.AddRectangle(10, 10); Shapes.Move(eat, x, y); Turtle.PenUp(); GraphicsWindow.KeyDown += GraphicsWindow_KeyDown; Random rand = new Random(); while (true) { Turtle.Move(10); if (Turtle.X >= x && Turtle.X <= x + 15 && Turtle.Y >= y && Turtle.Y <= y + 15) { x = rand.Next(0, GraphicsWindow.Width); y = rand.Next(0, GraphicsWindow.Height); Shapes.Move(eat, x, y); Turtle.Speed++; } } }
// ЦИКЛЫ. Цикл While. // GoodHouse рисует домик и возвращает черепашку в правильное место static void GoodHouse(int len) { // Рисуем тело домика Turtle.Turn(90); Square(len); // Рисуем крышу Turtle.Turn(-60); Turtle.Move(len); Turtle.Turn(120); Turtle.Move(len); Turtle.Turn(30); // Рисуем окошко Turtle.PenUp(); Turtle.Move(2 * len / 3); Turtle.Turn(90); Turtle.Move(len / 3); Turtle.PenDown(); Square(len / 3); Turtle.PenUp(); Turtle.Move(2 * len / 3); Turtle.TurnRight(); Turtle.Move(2 * len / 3); Turtle.PenDown(); }
static void Main(string[] args) { Turtle.Speed = 10; Turtle.X = 200; Turtle.Y = 200; { WriteT(60); Turtle.X = 260; Turtle.Y = 200; Turtle.Angle = 0; WriteO(30); } Turtle.X = 320; Turtle.Y = 200; Turtle.Angle = 0; Turtle.Move(30); for (int i = 0; i < 4; i++) { Turtle.TurnRight(); Turtle.Move(20); } Turtle.X = 380; Turtle.Y = 200; WriteT(30); }
static void Main(string[] args) { GraphicsWindow.KeyDown += GraphicsWindow_KeyDown; Turtle.PenUp(); GraphicsWindow.BrushColor = "Green"; var eat = Shapes.AddRectangle(10, 10); int x, y, life = 3; int score = 0; Random rand = new Random(); x = rand.Next(0, GraphicsWindow.Width); y = rand.Next(0, GraphicsWindow.Height); Shapes.Move(eat, x, y); while (life > 0) { Turtle.Move(1); 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++; score++; GraphicsWindow.DrawText(GraphicsWindow.Width - 100, GraphicsWindow.Height - 100, score); } else if (Turtle.X < 0 || Turtle.X > GraphicsWindow.Width || Turtle.Y < 0 || Turtle.Y > GraphicsWindow.Height) { Turtle.X = GraphicsWindow.Width / 2; Turtle.Y = GraphicsWindow.Height / 2; life--; } } }
static void Main(string[] args) { Console.WriteLine("----------------------------"); Console.WriteLine(" hello in my turtle program"); Console.WriteLine("----------------------------"); Console.Write("input turtle speed not bigger than 9: "); int speed = Convert.ToInt32(Console.ReadLine()); if (speed <= 9) { Console.Write("How much times turtle will drow a square: "); int times = Convert.ToInt32(Console.ReadLine()); Turtle.Speed = speed; int i = 0; while (i < times) { Turtle.Move(100); Turtle.TurnRight(); Turtle.Move(100); Turtle.TurnRight(); Turtle.Move(100); Turtle.TurnRight(); Turtle.Move(100); Turtle.TurnRight(); i++; } } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("faster than sonic!!"); Console.ReadKey(); } }
public void Turtle_ShouldBeSuccess(string moves) { foreach (var m in moves) { if (m == 'M') { turtle.Move(); } else { turtle.Turn(m); } } Assert.Equal("Success", turtle.Status); }
static void O(int size) { Turtle.Angle = 0; for (int i = 0; i < 4; i++) { Turtle.Move(size); } }
static void letterO() { for (int i = 0; i < 4; i++) { Turtle.Move(60); Turtle.TurnRight(); } }
public void Turtle_PlacedAndMoved_ReportsCorrectPosition() { var Turtle = new Turtle(); Turtle.Place(1, 1, Facing.North); Turtle.Move(); Assert.AreEqual("1,2,NORTH", Turtle.Report()); }
public void Turtle_InitialisedButNotPlaced_CannotBeMoved() { var Turtle = new Turtle(); var result = Turtle.Move(); Assert.IsFalse(result); Assert.AreEqual("Turtle cannot move until it has been placed on the table.", Turtle.LastError); }
public void Interpret(out Mesh meshBranches, out Mesh meshLeaves) { Turtle turtle = new Turtle(Eval(initialWidth)); foreach (var elem in str){ switch (elem.symbol){ case LSElement.LSSymbol.LEAF: AddLeaf (turtle.Peek().M,elem.data [0], elem.data [1], turtle.GetDist()); break; case LSElement.LSSymbol.DRAW: float movDist = elem.data [0]; AddCone(turtle.Peek().M, movDist, turtle.GetWidth(), turtle.GetWidth() * elem.data[1], turtle.GetDist()); turtle.Move(movDist); break; case LSElement.LSSymbol.TURN: turtle.Turn(elem.data[0]); break; case LSElement.LSSymbol.ROLL: turtle.Roll(elem.data[0]); break; case LSElement.LSSymbol.PUSH_STATE: turtle.Push(); break; case LSElement.LSSymbol.POP_STATE: turtle.Pop(); break; case LSElement.LSSymbol.WIDTH: turtle.SetWidth(elem.data[0]); break; case LSElement.LSSymbol.GRAVITY: turtle.Gravity(elem.data[0]); break; } } float max = 0; foreach (var u in uvLeafs) { max = Mathf.Max (u.x, max); } for (int i = 0; i < uvs.Count; i++) { uvs [i] = new Vector2( uvs [i].x/max,0); } for (int i = 0; i < uvLeafs.Count; i++) { uvLeafs [i] = new Vector2( uvLeafs[i].x/max ,0); } meshBranches = new Mesh(); if (vertices.Count >= 65536) { Debug.LogError ("Tree - too many verts: "+vertices.Count); } else { vertCount = vertices.Count; meshBranches.vertices = vertices.ToArray (); meshBranches.triangles = indices.ToArray (); meshBranches.uv = uvs.ToArray (); PostprocessMesh (meshBranches); //Debug.Log ("vertices "+vertices.Count); } uvs.Clear(); vertices.Clear(); indices.Clear(); meshLeaves = new Mesh(); if (verticesLeaf.Count >= 65536) { Debug.LogError ("Tree leaves - too many verts: "+verticesLeaf.Count); } else { vertLeafCount = verticesLeaf.Count; meshLeaves.vertices = verticesLeaf.ToArray (); meshLeaves.triangles = indicesLeaf.ToArray (); meshLeaves.uv = uvLeafs.ToArray (); PostprocessMesh (meshLeaves); } uvLeafs.Clear(); verticesLeaf.Clear(); indicesLeaf.Clear(); }