473,395 Members | 2,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to add animation to a program or code?

mkannah
Hi, i've been wondering how some program using codes is animated?
Sep 7 '13 #1

✓ answered by weaknessforcats

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:

Expand|Select|Wrap|Line Numbers
  1. #include <windows.h>
  2.  
  3. ostream&  pause(ostream& os)
  4. {
  5.      Sleep(500);
  6.      return os;
  7. }
  8.  
  9. int main()
  10. {
  11.     char* str1 = "*     ";
  12.     char* str2 = " *    ";
  13.     char* str3 = "  *   ";
  14.     char* str4 = "   *  ";
  15.     char* str5 = "    * ";
  16.  
  17.     cout << str1 <<pause << "\r"
  18.               << str2 <<pause << "\r"
  19.               << str3<<pause << "\r"
  20.               << str4 <<pause << "\r"
  21.               << str5 <<pause << endl;
  22.  
  23. }
  24.  

3 2506
weaknessforcats
9,208 Expert Mod 8TB
The same way they do it in the movies: Display an image over and over on top of itself.
Sep 7 '13 #2
Image? You mean characters? Like '*' ? Thanks.
Sep 7 '13 #3
weaknessforcats
9,208 Expert Mod 8TB
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:

Expand|Select|Wrap|Line Numbers
  1. #include <windows.h>
  2.  
  3. ostream&  pause(ostream& os)
  4. {
  5.      Sleep(500);
  6.      return os;
  7. }
  8.  
  9. int main()
  10. {
  11.     char* str1 = "*     ";
  12.     char* str2 = " *    ";
  13.     char* str3 = "  *   ";
  14.     char* str4 = "   *  ";
  15.     char* str5 = "    * ";
  16.  
  17.     cout << str1 <<pause << "\r"
  18.               << str2 <<pause << "\r"
  19.               << str3<<pause << "\r"
  20.               << str4 <<pause << "\r"
  21.               << str5 <<pause << endl;
  22.  
  23. }
  24.  
Sep 7 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Cyrus Lan | last post by:
I have a jar file, without source code, say abc.jar. I have set it in the CLASSPATH The main execute class in abc.jar is a.class. In the command prompt, I can execute the program by issuing...
1
by: Silver | last post by:
Hi everyone, I'm writing a program that has to do them following main() : ------- 3 objects are declared (two of type A and one of type B) The function frd_fun is called for two objects (B...
10
by: Vince | last post by:
The following is code for the classic tortoise and hare C assignment. I am posting this for educational purposes only. Please do not plagiarize as comp sci instructors regularly read newsgroups....
1
by: Hartmut Schroth | last post by:
Hello, I want to set the title of an aspx-page by program (from a localized ressource). Data binding in the HTML code like <title><%# SomeMethodCall() %></title> doesn't work. I have not found...
7
by: Mike | last post by:
What i want to do is have my c++ program, run a DOS program and copy a script from that DOS program to a file. I simply have no idea, how, or if it's plausable, to run DOS within a c++ program. ...
1
by: Evando | last post by:
I need a possible solution to tackle my assignment.The instruction again is to write a program code in C to convert from Roman numbers into Decimals.Any possible solution which will run is needed. ...
39
by: mike3 | last post by:
Hi. I was writing a program in C++ that generates fractals. I got this weird bug though right now that's holding it up and was wondering if you could help. Anyway, it seems that when this...
0
by: mike3 | last post by:
Hi. Just wanted to inform you that the code for the C++ fractal program has been taken down, the one that I had been debugging and was discussed in the threads "Bug in my C++ program seems...
1
by: randy18h | last post by:
Output: Enter a Value: //x6 Menu 1. Search 2. Locate for an index Choice: //if chosen 1: sample// Enter a value to search: 6 6
4
by: sherty | last post by:
need a c program code with run time error in the code.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.