ascii art video (8)

1 Name: #!/usr/bin/anonymous : 2007-03-30 12:58 ID:i/U9NfhD

here's a little one i wrote last month... it's pretty basic. If you want to make your own animation, use the header file for reference

/*
ascii animated video program
To create an AAV, simply create a text file with the following format
3 <--- height of current frame
000 \
000 |---content of frame (doesn't matter how wide, as long as it's the same hight as specified
000 /
1 <--- how long the frame lasts in seconds (can be a decimal value, e.g 0.04 is 1/25th of a second
just keep on adding sections like this to build it up frame by frame
enjoy!
(copyright 2007 dominic rudkin, distriputed under the lesser GPL)
*/

#include <iostream>
#include <stdio.h>
#include <time.h>
#include<cstdlib>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;

void wait ( double seconds )
{
clock_t endwait;
endwait = clock () + static_cast<long int>(seconds * CLOCKS_PER_SEC) ;
while (clock() < endwait) {}
}

int main()
{
string line,filename;
int height;
double frame;

cout << "Enter filename: ";
cin >> filename;
ifstream file(filename.c_str());

if(!file)
{
cerr << "Error opening file " << filename <<endl;
return EXIT_FAILURE;
}
vector<std::string> contents_of_file;

while(getline(file, line))
{
contents_of_file.push_back(line);
height = static_cast<int>(strtod(line.c_str(), NULL));
while (height > 0)
{
system("cls"); // Use this if you're on windows
//system("clear"); comment out above and uncomment this if you're running linux/unix
getline(file, line);
contents_of_file.push_back(line);
cout << line << endl;
height = height-1;
}
getline(file, line);
contents_of_file.push_back(line);
frame = strtod(line.c_str(), NULL);
wait (frame);
}
}
This thread has been closed. You cannot post in this thread any longer.