How to add animation to a program or code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mkannah
    New Member
    • Sep 2013
    • 6

    How to add animation to a program or code?

    Hi, i've been wondering how some program using codes is animated?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    The same way they do it in the movies: Display an image over and over on top of itself.

    Comment

    • mkannah
      New Member
      • Sep 2013
      • 6

      #3
      Image? You mean characters? Like '*' ? Thanks.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        You can use characters if you want, like *. For example:

        These strings are displayed on top of each other with a 1/2 pause between display. The effect is to see the * travel across the screen:

        Code:
        #include <windows.h>
        
        ostream&  pause(ostream& os)
        {
        	 Sleep(500);
        	 return os;
        }
        
        int main()
        {
        	char* str1 = "*     ";
        	char* str2 = " *    ";
        	char* str3 = "  *   ";
        	char* str4 = "   *  ";
        	char* str5 = "    * ";
        
        	cout << str1 <<pause << "\r"
        	          << str2 <<pause << "\r"
        			  << str3<<pause << "\r"
        			  << str4 <<pause << "\r"
        			  << str5 <<pause << endl;
        
        }

        Comment

        Working...