public void AddShapeToList(ASCII_Shape shape, MovementTypes movementType, int linearDistance = 0) { switch (movementType) { case MovementTypes.Up_Down: shape.Add_Movement(new Movements.Up_Down(linearDistance)); break; case MovementTypes.Left_Right: shape.Add_Movement(new Movements.Left_Right(linearDistance)); break; case MovementTypes.Diagonal_BL_TR: shape.Add_Movement(new Movements.Diagonal_BL_TR(linearDistance)); break; case MovementTypes.Circle_CW: shape.Add_Movement(new Movements.Circle_CW()); break; case MovementTypes.Circle_CCW: shape.Add_Movement(new Movements.Circle_CCW()); break; case MovementTypes.Spiral_CW: shape.Add_Movement(new Movements.Spiral_CW()); break; } }
public static void MoveShape(ASCII_Shape shape, int NewLeft, int NewTop) { int previousLeft = shape.Left; int previousRight = previousLeft + (shape.shapeWidth - 1); int previousTop = shape.Top; int previousBot = shape.Top + (shape.shapeHeight - 1); int newLeft = NewLeft; int newRight = NewLeft + (shape.shapeWidth - 1); int newTop = NewTop; int newBot = NewTop + (shape.shapeHeight - 1); for (int i = newBot; i < newTop; i++) { for (int j = newLeft; j < newRight; j++) { } } }
static void Main(string[] args) { PUBV.Initialize_ConsoleArray(); string textString = "Hello hi this is a test so I'm just writing a really really really really long message that will be sure to jump down to the next line because hey, what else am I supposed to do to test this thing. If it works, then I will have proven an important theory; Anything can be boxed, organized and displayed on this console."; DrawingStuff.ASCII_Shape myTextBox = new DrawingStuff.ASCII_Shape(textString, 50); DrawingStuff.ASCII_Shape myAxe = new DrawingStuff.ASCII_Shape(DrawingStuff.DrawTool.ShapeTypes.Axe); DrawingStuff.ASCII_Shape mySword = new DrawingStuff.ASCII_Shape(DrawingStuff.DrawTool.ShapeTypes.Sword); DrawingStuff.ASCII_Shape mySideBar = new DrawingStuff.ASCII_Shape(PUBV.ConsoleHeight - 1, 30); DrawingStuff.DrawTool.AddImageToConsoleArrays_MovementLayer(10, 20, myTextBox); DrawingStuff.DrawTool.AddImageToConsoleArrays_StaticLayer(0, 0, mySideBar); DrawingStuff.DrawTool.Draw_ConsoleArrayLayers(); Array.Clear(PUBV.consoleArr_NeedsUpdate, 0, PUBV.consoleArr_NeedsUpdate.Length); ConsoleKey key = ConsoleKey.D9; bool dontCheck = false; for (; ;) { if (!dontCheck) { key = Console.ReadKey(true).Key; switch (key) { case ConsoleKey.W: DrawingStuff.ShapeMover.Move_Custom(myTextBox, DrawingStuff.ShapeMover.MoveDirections.up); break; case ConsoleKey.S: DrawingStuff.ShapeMover.Move_Custom(myTextBox, DrawingStuff.ShapeMover.MoveDirections.down); break; case ConsoleKey.D: DrawingStuff.ShapeMover.Move_Custom(myTextBox, DrawingStuff.ShapeMover.MoveDirections.right); break; case ConsoleKey.A: DrawingStuff.ShapeMover.Move_Custom(myTextBox, DrawingStuff.ShapeMover.MoveDirections.left); break; case ConsoleKey.Q: DrawingStuff.ShapeMover.Move_Custom(myTextBox, DrawingStuff.ShapeMover.MoveDirections.up_left); break; case ConsoleKey.E: DrawingStuff.ShapeMover.Move_Custom(myTextBox, DrawingStuff.ShapeMover.MoveDirections.up_right); break; case ConsoleKey.Z: DrawingStuff.ShapeMover.Move_Custom(myTextBox, DrawingStuff.ShapeMover.MoveDirections.down_left); break; case ConsoleKey.C: DrawingStuff.ShapeMover.Move_Custom(myTextBox, DrawingStuff.ShapeMover.MoveDirections.down_right); break; default: // Do nothing break; } } else { DrawingStuff.ShapeMover.StepAllShapes(); } DrawingStuff.DrawTool.Draw_ConsoleArrayLayers(); } }
public static void Initialize_NewShape(DrawingStuff.ASCII_Shape newShape) { PriorityList_Shapes.Add(newShape); }
/// <summary> /// Add an image into the static background layer (newest is highest priority.) /// </summary> /// <param name="StartLeft"></param> /// <param name="StartTop"></param> /// <param name="shape"></param> public static void AddImageToConsoleArrays_StaticLayer(int StartLeft, int StartTop, ASCII_Shape shape) { List <string> lStrings = shape.lStrings; List <string> lColors = shape.lColors; int Left = StartLeft; int Top = StartTop; char nextChar; shape.Left = Left; shape.Top = Top; // The char that will carry down to the lower priority array char shuttleChar = '\0'; char shuttleChar_Color = '\0'; for (int i = 0; i < lStrings.Count; i++) { char[] rowChars = lStrings[i].ToCharArray(); char[] rowColors = lColors[i].ToCharArray(); for (int j = 0; j < rowChars.Length; j++) { // Get rid of blanks if (rowChars[j] == ' ') { rowChars[j] = '\0'; } // *ADD blanks where the omit char is (inside of solid objects aren't transparent) if (rowChars[j] == omitChar) { nextChar = ' '; } else { nextChar = rowChars[j]; } // Don't process blanks if (nextChar != '\0') { //**** Need this? PUBV.consoleArr_NeedsUpdate[Top + i, Left + j] = true; // Try Array1 if (PUBV.consoleArr_Static1[Top + i, Left + j] == '\0') { PUBV.consoleArr_Static1[Top + i, Left + j] = nextChar; PUBV.consoleArr_Static1_Colors[Top + i, Left + j] = rowColors[j]; } else { shuttleChar = PUBV.consoleArr_Static1[Top + i, Left + j]; shuttleChar_Color = PUBV.consoleArr_Static1_Colors[Top + i, Left + j]; PUBV.consoleArr_Static1[Top + i, Left + j] = nextChar; PUBV.consoleArr_Static1_Colors[Top + i, Left + j] = rowColors[j]; } // If there is a character to shuttle if (shuttleChar != '\0') { // Try Array2 if (PUBV.consoleArr_Static2[Top + i, Left + j] == '\0') { // Empty spot found PUBV.consoleArr_Static2[Top + i, Left + j] = shuttleChar; PUBV.consoleArr_Static2_Colors[Top + i, Left + j] = shuttleChar_Color; shuttleChar = '\0'; shuttleChar_Color = '\0'; } else { // Spot's taken shuttleChar = PUBV.consoleArr_Static2[Top + i, Left + j]; shuttleChar_Color = PUBV.consoleArr_Static2_Colors[Top + i, Left + j]; PUBV.consoleArr_Static2[Top + i, Left + j] = shuttleChar; PUBV.consoleArr_Static2_Colors[Top + i, Left + j] = shuttleChar_Color; } // If there is still a character to shuttle if (shuttleChar != '\0') { // Try Array3 if (PUBV.consoleArr_Static3[Top + i, Left + j] == '\0') { // Empty spot found PUBV.consoleArr_Static3[Top + i, Left + j] = shuttleChar; PUBV.consoleArr_Static3_Colors[Top + i, Left + j] = shuttleChar_Color; } else { // Spot's taken shuttleChar = PUBV.consoleArr_Static3[Top + i, Left + j]; shuttleChar_Color = PUBV.consoleArr_Static3_Colors[Top + i, Left + j]; PUBV.consoleArr_Static3[Top + i, Left + j] = shuttleChar; PUBV.consoleArr_Static3_Colors[Top + i, Left + j] = shuttleChar_Color; } // Add more arrays to extend this shuttleChar = '\0'; shuttleChar_Color = '\0'; } } } } Left = StartLeft; } Console.SetCursorPosition(0, 0); Console.CursorVisible = false; }
/// <summary> /// Add an image into the movement layer (Image must have movement orders) /// </summary> /// <param name="StartLeft"></param> /// <param name="StartTop"></param> /// <param name="shape"></param> public static void AddImageToConsoleArrays_MovementLayer(int StartLeft, int StartTop, ASCII_Shape shape, bool OverwriteOld = false) { List <string> lStrings = shape.lStrings; List <string> lColors = shape.lColors; int Left = StartLeft; int Top = StartTop; char nextChar; shape.Left = Left; shape.Top = Top; for (int i = 0; i < lStrings.Count; i++) { char[] rowChars = lStrings[i].ToCharArray(); char[] rowColors = lColors[i].ToCharArray(); for (int j = 0; j < rowChars.Length; j++) { if (rowChars[j] == omitChar) { nextChar = ' '; } else { nextChar = rowChars[j]; } // Don't process blanks if (nextChar != '\0') { // If checked spot is empty, then add. Else, do nothing. if (Top + i >= 0 && Left + j >= 0) { if (PUBV.consoleArr_MovementLayer[Top + i, Left + j] == '\0' || OverwriteOld == true) { PUBV.consoleArr_MovementLayer[Top + i, Left + j] = nextChar; PUBV.consoleArr_MovementLayer_Colors[Top + i, Left + j] = rowColors[j]; PUBV.consoleArr_NeedsUpdate[Top + i, Left + j] = true; } } } } } Console.CursorVisible = false; Console.SetCursorPosition(0, 0); }
public static void Move_Custom(ASCII_Shape shape, MoveDirections directionToMove) { int Top = shape.Top; int Left = shape.Left; int shapeHeight = shape.shapeHeight; int shapeWidth = shape.shapeWidth; if (directionToMove != MoveDirections.Wait) { int newTop = 0; int newLeft = 0; int eraseTop = 0; int eraseBot = 0; int eraseLeft = 0; int eraseRight = 0; int eraseHeight = 0; int eraseWidth = 0; bool diagonalMove = false; //|| Tall - 0,1,2 || Wide - 0,1,2 || int[,] arrEraseInts = new int[2, 4]; switch (directionToMove) { case MoveDirections.up: { newTop = Top - UDInterval; newLeft = Left; eraseTop = Top + (shapeHeight - 1); eraseBot = Top + (shapeHeight - 1) + UDInterval; eraseLeft = Left; eraseRight = Left + shapeWidth; clearIt(eraseTop, eraseLeft, eraseBot, eraseRight); break; } case MoveDirections.down: { newTop = Top + UDInterval; newLeft = Left; eraseTop = Top; eraseBot = Top + UDInterval; eraseLeft = newLeft; eraseRight = newLeft + shapeWidth; clearIt(eraseTop, eraseLeft, eraseBot, eraseRight); break; } case MoveDirections.left: { newTop = Top; newLeft = Left - LRInterval; eraseTop = newTop; eraseBot = newTop + shapeHeight; eraseLeft = newLeft + shapeWidth; eraseRight = eraseLeft + LRInterval; clearIt(eraseTop, eraseLeft, eraseBot, eraseRight); break; } case MoveDirections.right: { newTop = Top; newLeft = Left + LRInterval; eraseTop = newTop; eraseBot = newTop + shapeHeight; eraseLeft = Left; eraseRight = Left + LRInterval; clearIt(eraseTop, eraseLeft, eraseBot, eraseRight); break; } case MoveDirections.up_left: { diagonalMove = true; newTop = Top - UDInterval; newLeft = Left - LRInterval; //------------------ // Erase Tall Area //------------------ { eraseTop = Top; eraseBot = Top + shapeHeight; eraseLeft = Left + shapeWidth - LRInterval; eraseRight = Left + shapeWidth; clearIt(eraseTop, eraseLeft, eraseBot, eraseRight); } //------------------ // Erase Wide Area //------------------ { eraseTop = Top + shapeHeight - UDInterval; eraseBot = eraseTop + UDInterval; eraseLeft = Left; eraseRight = Left + shapeWidth; clearIt(eraseTop, eraseLeft, eraseBot, eraseRight); } break; } case MoveDirections.down_left: { diagonalMove = true; newTop = Top + UDInterval; newLeft = Left - LRInterval; //------------------ // Erase Tall Area //------------------ { eraseTop = Top; eraseBot = Top + shapeHeight; eraseLeft = Left + shapeWidth - LRInterval; eraseRight = Left + shapeWidth; clearIt(eraseTop, eraseLeft, eraseBot, eraseRight); } //------------------ // Erase Wide Area //------------------ { eraseTop = Top; eraseBot = Top + UDInterval; eraseLeft = Left; eraseRight = eraseLeft + shapeWidth; clearIt(eraseTop, eraseLeft, eraseBot, eraseRight); } break; } case MoveDirections.up_right: { diagonalMove = true; newTop = Top - UDInterval; newLeft = Left + LRInterval; //------------------ // Erase Tall Area //------------------ { eraseTop = Top; eraseBot = Top + shapeHeight; eraseLeft = Left; eraseRight = Left + LRInterval; clearIt(eraseTop, eraseLeft, eraseBot, eraseRight); } //------------------ // Erase Wide Area //------------------ { eraseTop = Top + shapeHeight - UDInterval; eraseBot = Top + shapeHeight; eraseLeft = Left; eraseRight = Left + shapeWidth; clearIt(eraseTop, eraseLeft, eraseBot, eraseRight); } break; } case MoveDirections.down_right: { diagonalMove = true; newTop = Top + UDInterval; newLeft = Left + LRInterval; //------------------ // Erase Tall Area //------------------ { eraseTop = Top; eraseBot = Top + shapeHeight; eraseLeft = Left; eraseRight = Left + LRInterval; clearIt(eraseTop, eraseLeft, eraseBot, eraseRight); } //------------------ // Erase Wide Area //------------------ { eraseTop = Top; eraseBot = Top + UDInterval; eraseLeft = Left; eraseRight = Left + shapeWidth; clearIt(eraseTop, eraseLeft, eraseBot, eraseRight); } break; } default: newTop = Top; newLeft = Left; eraseTop = Top; eraseBot = Top; eraseLeft = Left; eraseRight = Left; break; } /* * * //================================ * // *** NEW STUFF *** * //================================ * * if (eraseTop < 0) { eraseTop = 0; } * if (eraseLeft < 0) { eraseLeft = 0; } * for (int i = eraseTop; i < eraseBot; i++) * { * for (int j = eraseLeft; j < eraseRight; j++) * { * PUBV.consoleArr_MovementLayer[i, j] = '\0'; * PUBV.consoleArr_NeedsUpdate[i, j] = true; * } * } */ DrawTool.AddImageToConsoleArrays_MovementLayer(newLeft, newTop, shape, true); Left = newLeft; Top = newTop; } void clearIt(int eraseTop, int eraseLeft, int eraseBot, int eraseRight) { //================================ // *** NEW STUFF *** //================================ if (eraseTop < 0) { eraseTop = 0; } if (eraseLeft < 0) { eraseLeft = 0; } for (int i = eraseTop; i < eraseBot; i++) { for (int j = eraseLeft; j < eraseRight; j++) { PUBV.consoleArr_MovementLayer[i, j] = '\0'; PUBV.consoleArr_NeedsUpdate[i, j] = true; } } } }