0

Not sure if this is technically possible, but I've been trying my best;

What I'm trying to do is make an effect where the characters in the console output slide out to the left. To give that effect, I tried deleting the first character of every line in the console output, however, when I move my key to the line in the console, it only deletes the character itself, but doesn't move back the rest of the characters in the line.

If there isn't another easy way about it, I thought about moving the cursor to each character in the console output, however, I do not know how to have the code detect what is currently at the cursor, so in that regard, I am stuck with the current libraries and extensions that I know.

The point in all of this is only for adding visual animations using the console application that is pleasing to the eye, what should I do to achieve this?

        static void Clear_Paper()
        {
            Console.WriteLine("qwerty");
            Console.WriteLine("qwerty");
            Console.WriteLine("qwerty");
            Console.WriteLine("qwerty");
            for (int i = 0; i < 10; i++)
            {
                for (int y = 0; y < 4; y++)
                {
                    for (int x = 0; x < 6; x++)
                    {
                        Console.SetCursorPosition(x, y);
                        Thread.Sleep(50);
                    }
                    // Deletes first character of every line in console 
                    Console.SetCursorPosition(0, y);
                    Thread.Sleep(300);
                    Console.Write("\0 ");
                }
            }
        }

Here is a visual explanation :

What I want What I want

What I tried using Console.Write("\0 ") in the first letter What I tried using Console.Write("\0 ") in the first letter

Where I am at so far Where I am at so far

VoodooJazz_
  • 47
  • 1
  • 7
  • Store input in array, manipulate with array (e.g. removing first character) and just output it on the screen overwriting previous content. – Sinatr Aug 05 '21 at 14:32
  • I thought of using arryas as well at first, but the problem is that not everything I'm using is being printed out all in one variable, and some elements that are printed out weren't declared as variables in the first place (In my long project at least). Though your idea would work using the example I made, where you make a string[] holding qwerty, delete first letter of the array, clear console and print it out again – VoodooJazz_ Aug 05 '21 at 14:34
  • What I'm looking for is a solution that directly affects the console output, if there isn't a way then I guess il have to re-think my current project – VoodooJazz_ Aug 05 '21 at 14:38
  • What are you trying to achieve? If something else does the output, why do you want to change it? You can [intercept](https://stackoverflow.com/q/6024172/1997232) output. – Sinatr Aug 05 '21 at 14:38
  • @Sinatr Oh! I think that helps me on exactly what I need I think. Its all in a text file called "ConsoleOutput.txt"? I didn't know that. – VoodooJazz_ Aug 05 '21 at 14:43
  • Not exactly Olivier, I'm not trying to catch a key input, but the help is appreciated – VoodooJazz_ Aug 05 '21 at 14:44
  • @Sinatr Ok. So, I think that intercepting is a good plan for what I'm trying to do. To explain what I'm trying to achieve, I was to move what was originally written to the console to the left side of the screen, while deleting the first letter in order to give the effect that it's moving away. Rather than doing a Console.Clear() I wanted to give a special exit to what remains of the code, like a white board being erased with a rag – VoodooJazz_ Aug 05 '21 at 14:53
  • To scroll (animate) content of current console output you have to read it, either by intercepting all output and storing it or [like here](https://stackoverflow.com/a/51041803/1997232) and then just play animation by modifying the value and rendering it in a loop. – Sinatr Aug 05 '21 at 14:57
  • @Sinatr Awesome, Thank you ! Il try to make use of these tools as mentioned – VoodooJazz_ Aug 05 '21 at 15:08

0 Answers0