When drawing something using the console, what different ways can you use to do, and can basic animation be created???
When drawing something using the console, what different ways can you use to do, and can basic animation be created???
ASCII "art" or some form of a graphics library is the simple answer. There are a number of graphics libraries available. Graphic libraries are designed for this sort of thing, but are not generally considered beginner type projects. Moving ASCII char around the screen can be an interesting learning project.
Do you have any idea about how to start on a basic console animation program?
I can think of a very very long winded way of doing it, but its nt very efficient, it goes as follows...
This code will not compile because I have forgotten the header needed to use the sleep function, if anyone knows, then please share it with the rest of us...Code:#include <iostream> #include <stdlib.h> #include <conio.h> #include <stdio.h> using namespace std; int main(int argc, char *argv[]) { while(1) // can be done with out this { // Draw a frame here... sleep(0.04); //Draw next frame here... sleep(0.04); //Keep on doing this, and you will end up with a short animated sequence... //End the loop } system("PAUSE"); return 0; }
Last edited by Finchie_88; 10-22-2004 at 11:56 AM.
That's the basics of it. Graphics libraries talk in terms of frames per second instead of Sleep(), but it's the same principle.
I believe you can find Sleep() in windows.h, but don't quote me on that.
If you are using iostream.h and using namespace std;, then I'd suggest you also use cstdio, cstdlib, cmath, ctime, cctype, etc. as well. They are the "latest and greatest versions" of the older C libraries.