Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

ascii animation

Name: polymorph !3GqYIJ3Obs 2007-03-30 8:15 ID:P2cRkSb8

here's a little something i whipped up
( just a side note - ifstream file(filename.c_str()); has a problem with spaces in paths, so if you're running windows just put the text file you want animated in your C:\ directory.)

    /*
    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);
    }
    }

Name: Anonymous 2007-04-01 20:10 ID:4qbKEZaR

fuck you asshole

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List