Name: a nonny mouse 2007-05-01 19:06 ID:3AyWbj5L
here's a take two of the ascii art animator, now in optimized for memory & header file format
/*
ascii animated video program
To create an AAV, simply create a text file with the following format
1 or 0 <---- put at top of the file. How many numbers indicates how many passes. -1 indicates an infinite loop
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!
(thanks for the insults and better code from the /prog/ assholes)
(copyright 2007 dominic rudkin, released under the lesser gpl)
*/
#include <iostream>
#include <stdio.h>
#include <time.h>
#include <fstream>
#include <vector>
#define WINDOWS
using namespace std;
void clear();
int animate(string filename)
{
string line;
int height,loop,dummy;
double frame;
ifstream file(filename.c_str());
if(!file)
{
cerr << "Error opening file " << filename <<endl;
return EXIT_FAILURE;
}
vector<std::string> contents_of_file;
getline(file, line);
loop = static_cast<int>(strtod(line.c_str(), NULL));
do
{
ifstream file(filename.c_str());
getline(file, line);
dummy = static_cast<int>(strtod(line.c_str(), NULL));
while(getline(file, line))
{
contents_of_file.push_back(line);
height = static_cast<int>(strtod(line.c_str(), NULL));
while (height > 0)
{
getline(file, line);
contents_of_file.push_back(line);
cout << line << endl;
--height;
}
getline(file, line);
contents_of_file.push_back(line);
frame = strtod(line.c_str(), NULL);
contents_of_file.clear();
usleep(static_cast<int>(frame*1000000));
clear();
}
--loop;
}while (loop!=1);
return 0;
}
void clear()
{
#ifdef WINDOWS
system("clear");
#endif
#ifdef LINUX
system("clear");
#endif
}
/*
ascii animated video program
To create an AAV, simply create a text file with the following format
1 or 0 <---- put at top of the file. How many numbers indicates how many passes. -1 indicates an infinite loop
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!
(thanks for the insults and better code from the /prog/ assholes)
(copyright 2007 dominic rudkin, released under the lesser gpl)
*/
#include <iostream>
#include <stdio.h>
#include <time.h>
#include <fstream>
#include <vector>
#define WINDOWS
using namespace std;
void clear();
int animate(string filename)
{
string line;
int height,loop,dummy;
double frame;
ifstream file(filename.c_str());
if(!file)
{
cerr << "Error opening file " << filename <<endl;
return EXIT_FAILURE;
}
vector<std::string> contents_of_file;
getline(file, line);
loop = static_cast<int>(strtod(line.c_str(), NULL));
do
{
ifstream file(filename.c_str());
getline(file, line);
dummy = static_cast<int>(strtod(line.c_str(), NULL));
while(getline(file, line))
{
contents_of_file.push_back(line);
height = static_cast<int>(strtod(line.c_str(), NULL));
while (height > 0)
{
getline(file, line);
contents_of_file.push_back(line);
cout << line << endl;
--height;
}
getline(file, line);
contents_of_file.push_back(line);
frame = strtod(line.c_str(), NULL);
contents_of_file.clear();
usleep(static_cast<int>(frame*1000000));
clear();
}
--loop;
}while (loop!=1);
return 0;
}
void clear()
{
#ifdef WINDOWS
system("clear");
#endif
#ifdef LINUX
system("clear");
#endif
}