Help with Horizontal Scrolling ASCII image - "Hit Enter to continue...Esc to end"

This is a discussion on Help with Horizontal Scrolling ASCII image - "Hit Enter to continue...Esc to end" within the C++ Programming forums, part of the General Programming Boards category; I would like the coded ASCII image to scroll horizontally 3 times and then end with the message: " Hit ...

  1. #1
    Registered User
    Join Date
    Aug 2013
    Posts
    2

    Question Help with Horizontal Scrolling ASCII image - "Hit Enter to continue...Esc to end"

    I would like the coded ASCII image to scroll horizontally 3 times and then end with the message:

    "Hit Enter to continue or Esc to end"

    If Enter is pressed, the program should then continue to scroll another 3 times and then display the same message above.

    If Esc is hit then the program loop should stop similar to an escape sequence.

    Here is my code that partially accomplishes my objective:

    Code:
    // Professor.cpp : The entry point for the console application.
    
    #include <iostream>
    #include <string>
    #include <windows.h>
    #include <stdlib.h>
    
    using namespace std;
    
    HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD CursorPosition;
    
    void gotoXY(int x, int y, string text);
    void gotoXY(int x, int y);
    
    int main(int)
    {
        string Professor[]=
        {"                                     "
        ,"            _.-\"""""\"\"""""\"-._                "                    
        ,"           /.-......-.\\                   "
        ,"          //          \\\                   "                   
        ,"          ||          ||                   "
        ,"          ||./\\    /\\.||                   "
        ,"          /` ** || ** '\\                   "
        ,"          \\     /\\     /                   "
        ,"           |   (__)   |                  "
        ,"           |  ,____,  |                   "
        ,"            \\  `--'   /                   "
        ,"         _./`'.____.'`\\._                   "
        ,"     _.-'  \\  \\   /  /  '-._                   "
        ,"  /         \\  `\\/`  /         \\                   "
        ,"  /          \\./  \\./          \\                   "
        ,"  /                            \\                   "
        ,"                                     "};
        
        char holder = ' ';
    
        int len, x, y;
    
        len = Professor[0].length();
        
        do{
            for (y=0;y<17;y++)
            {
                gotoXY(17,1+y,Professor[y]);
            }
        
            for (y=0;y<17;y++)
            {
                holder = Professor[y][len];
                for (x=len;x>0;x--)
                {
                    Professor[y][x]=Professor[y][x-1];
                }
                Professor[y][0]=holder;
            }
    
    Sleep(120);
        }while(true);
    return 0;
    system("PAUSE");
    }
    
    
    
    void gotoXY(int x, int y, string text) 
    { 
        CursorPosition.X = x; 
        CursorPosition.Y = y; 
        SetConsoleCursorPosition(console,CursorPosition);
        cout << text;
    }
    
    void gotoXY(int x, int y) 
    { 
        CursorPosition.X = x; 
        CursorPosition.Y = y;
    }
    Thank you for your suggestions and comments.

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    That professor's freaking me out, man!!!

    Since this is C++, not C, it should go in the C++ forum.
    The moderators will move it for you.

    * main's argument list should be empty or (int argc, char **argv).
    * You have an extra \ on line 22 (3 in a row).
    * Your system("pause") should go before the return statement in main!
    * Your gotoXY function that prints a string should probably be called something like printXY.
    * The other gotoXY function is lacking the SetConsoleCursorPosition call.
    * Get that gotoXY working and use it from your printXY function.

    So you want to be able to stop this insane man. Firslty, fix the above and get it to just scroll 3 times, then we can work on the keyboard control.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  3. #3
    Registered User
    Join Date
    Aug 2013
    Posts
    2
    Made some progress but still need help.

    Code:
    // Professor.cpp : The entry point for the console application.
     
    #include <iostream>
    #include <string>
    #include <windows.h>
    #include <stdlib.h>
     
    using namespace std;
     
    HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD CursorPosition;
     
    void printXY(int x, int y, string text);
    void gotoXY(int x, int y, string text);
     
    int main()
    {
        string Professor[]=
        {"                                     "
        ,"            _.-\"""""\"\"""""\"-._                "
        ,"           /.-......-.\\                   "
        ,"          //          \\                   "
        ,"          ||          ||                   "
        ,"          ||./\\    /\\.||                   "
        ,"          /` ** || ** '\\                   "
        ,"          \\     /\\     /                   "
        ,"           |   (__)   |                  "
        ,"           |  ,____,  |                   "
        ,"            \\  `--'   /                   "
        ,"         _./`'.____.'`\\._                   "
        ,"     _.-'  \\  \\   /  /  '-._                   "
        ,"  /         \\  `\\/`  /         \\                   "
        ,"  /          \\./  \\./          \\                   "
        ,"  /                            \\                   "
        ,"                                     "};
         
        char holder = ' ';
     
        int len, x, y;
     
        len = Professor[0].length();
         
        do{
            for (y=0;y<17;y++)
            {
                gotoXY(17,1+y,Professor[y]);
            }
         
            for (y=0;y<17;y++)
            {
                holder = Professor[y][len];
                for (x=len;x>0;x--)
                {
                    Professor[y][x]=Professor[y][x-1];
                }
                Professor[y][0]=holder;
            }
     
    Sleep(120);
        }while(true);
    system("PAUSE");
    return 0;
    }
     
     
     
    void printXY(int x, int y, string text)
    {
        CursorPosition.X = x;
        CursorPosition.Y = y;
        SetConsoleCursorPosition(console,CursorPosition);
        cout << text;
    }
     
    void gotoXY(int x, int y, string text)
    {
        CursorPosition.X = x;
        CursorPosition.Y = y;
        SetConsoleCursorPosition(console,CursorPosition);
        cout << text;
    }

  4. #4
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Made some progress

    Not enough for me to say anything new.
    Try making it scroll "three times" as you want it to.
    If you actually wrote the code, then that should be easy.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Option to "Continue or Quit" will not work.
    By steveryan in forum C Programming
    Replies: 12
    Last Post: 11-09-2012, 03:54 PM
  2. "press any key to continue" without the enter key
    By chickenandfries in forum C Programming
    Replies: 1
    Last Post: 03-29-2008, 09:56 PM
  3. "Press any key to continue" Error on console
    By c# Student in forum C# Programming
    Replies: 2
    Last Post: 10-19-2006, 10:04 AM
  4. Using "continue" (basic language problem)
    By DominicTrix in forum C++ Programming
    Replies: 5
    Last Post: 09-06-2004, 06:10 PM
  5. Replies: 5
    Last Post: 06-30-2003, 12:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21