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

Pages: 1-4041-

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-03-30 8:46 ID:P2cRkSb8

lol wut?

Name: Anonymous 2007-03-30 9:05 ID:GsvQs3lS

>system("cls"); // Use this if you're on windows
>//system("clear"); comment out above and uncomment this if you're running linux/unix

Forced commenting of the code by the user THREAD OVER

Name: Anonymous 2007-03-30 9:36 ID:cd7cF1nx

mplayer -vo aa 300.avi

Name: Anonymous 2007-03-30 9:43 ID:43sj7Ag4

>>3
You are kidding arent you ? That sounds preposterous to me. I think you need to re-examine your assumptions.

Name: Anonymous 2007-03-30 12:57 ID:cd7cF1nx

>>1
>strtod(line.c_str(), NULL);

boost::lexical_cast > strtod

Name: Anonymous 2007-03-30 13:03 ID:vr4Fn2S7

| while (clock() < endwait) {}
No.

Name: Anonymous 2007-03-30 13:17 ID:C3S4gf1w

>>3
MOAR LIEK DEFINE IS YOUR FRIEND FUCKTARD

#define WINDOWS

void CLEARTHATSHIT()
{
#ifdef WINDOWS
system("cls");
#endif
#ifdef LINUX
system("clear");
#endif
}

Name: Anonymous 2007-03-30 13:28 ID:C3S4gf1w

O BTW YOU NEVER CHANGE CODES YOU DON'T USE INTO COMMENTS BECAUSE IT FUCKS EVERYTHING UP IF YOU COMMENT YOUR CODES YOU SHALL USE #if 0

#if 0
SOMECODEETC/* THE COMMENTS AREN'T GONNA FUCK EVERYTHING UP BECAUSE THERE IS IF 0 NOT ANOTHER COMMENT ETC
ETC
ETC
ETC*/
MOAR CODE ETC
MOAR CODE ETC /*CRAPPY COMMENTS ETC*/
#endif

Name: Anonymous 2007-03-30 13:37 ID:5cWgaalB

height = height-1;
--height;

also, nanosleep().

Name: Anonymous 2007-03-30 15:00 ID:K1g3brAm

module Main where

import Control.Concurrent (threadDelay)

data Frame = Frame Int      -- height
                   Float    -- delay
                   [String] -- content
               deriving Show

-- GLOBAL WARMING: threadDelay will round to 1/50s! :(
wait :: Float -> IO ()
wait = threadDelay . truncate . (* 1000000)

extractFrames :: [String] -> [Frame]
extractFrames [] = []
extractFrames xs =
        let height     = read $ head xs
            (ys, rest) = splitAt (height + 2) xs
            content    = tail $ take (height + 1) ys
            delay      = read $ ys !! (height + 1)
         in (Frame height delay content) : extractFrames rest

pFrame :: Frame -> IO ()
pFrame (Frame _ d c) = mapM_ putStrLn c >> wait d

main :: IO ()
main = do
        putStr "Enter filename: " >> getLine >>= readFile >>=
         \xs -> let frames = extractFrames $ lines xs
          in mapM_ pFrame frames

Name: Anonymous 2007-03-30 16:43 ID:qwfe53FH

>>11
haskell ?

Name: Anonymous 2007-03-30 17:00 ID:JjbS6B6G

>>12
guh

Name: Anonymous 2007-03-30 18:52 ID:Heaven

>>8
>>9

I am >>3
What i quoted was on >>1's post i know about the define directive tard.

Name: Anonymous 2007-03-30 22:43 ID:P2cRkSb8

this better?
    /*
    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!
    (thanks for the insults and better code from the /prog/ assholes)
    (copyright 2007 dominic rudkin)
    */
   
    #include <iostream>
    #include <stdio.h>
    #include <time.h>
    #include<cstdlib>
    #include <fstream>
    #include <string>
    #include <vector>
    #include <sstream>
    #include <windows.h>
    #define WINDOWS
   
    using namespace std;
   
void clear()
{
#ifdef WINDOWS
system("cls");
#endif
#ifdef LINUX
system("clear");
#endif
}

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

int main()
{
string line,filename;
int height,loop;
double frame;
   
cout << "Enter filename: ";
cin >> filename;
cout << endl << "loop file? (1=yes, 0=no): ";
cin >> loop;
ifstream file(filename.c_str());
   
if(!file)
{
    cerr << "Error opening file " << filename <<endl;
    return EXIT_FAILURE;
}
vector<std::string> contents_of_file;
do
{
    ifstream file(filename.c_str());
    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();
        Sleep(static_cast<int>(frame*1000));
        clear();
    }
}while (loop==1);
return 0;
}

Name: Anonymous 2007-03-31 2:55 ID:gRbfiD40

>>10 thinks he is an expert programmer while he is an idiot who doesn't know even the basics.

Name: Anonymous 2007-03-31 15:28 ID:3XFQ1ZvO

>>16
NO YUO HAVE TO USE --height BECUASE IT IS FASTER THEN height--!!!!!!!!!!

Name: Anonymous 2007-03-31 16:13 ID:gZygw8DA

>>10 reads from right to left.

Name: Anonymous 2007-03-31 21:46 ID:Ctyuf0mV

>>15
You have to compile it twice once for windows once for linux.

Name: 10 2007-03-31 22:47 ID:clSjeizy

>>18
actually, yes i do.

Name: Anonymous 2007-03-31 22:49 ID:Heaven

i guess the IDs change on here.
shitty board is shit.

Name: Anonymous 2007-03-31 23:38 ID:he6TyR4e

--height woudl generate the same unoptimized opcodes:

mov reg,[ebp+height+stktmp]
dec reg
mov [ebp+height+stktmp],reg

same as height--

now if this were to be used in a real expresion, then it would have made a lot more sense... i suppose its a matter of preference wether you increment before or after, most compilers
would discard the 'reg' used for height-- after its usage, while --height would keep the reg IF used, however if it wasnt used in any expresion, it would have been pointless
so there would be no speed differences between the two
however if you use
height = height - 1
then the following code would be generated(HOPEFULLY, with an optimizing compiler):

mov reg,[ebp+height+stktmp]
sub reg,1 ; much slower than a simple dec or inc
mov [ebp+height+stktmp],reg

this actually performs a real substraction , not a optimized incrememnt/decrement instruction... for more details check out the microcode involved with each in your assembly book(preferably the one from intel)
substractions are only slightly slower than compares(actually a compare is the same thing as a substraction, just the result is not saved and only the flags are affected)

this applies to IA-32 Assembler.

Name: Anonymous 2007-03-31 23:47 ID:Heaven

>>22 is trolling or doesn't understand how compilers work. Any compiler that generates sub 1 instead of dec is broken.

Name: Anonymous 2007-04-01 0:04 ID:Heaven

>>23
k i was trolling on the opmizing compiler a bit, but lets view what
MSVC6++'s cl.exe (12.00.8804) generates without any parameters(default optimizations):

main()
{
    int a=0;
    a++;
    a+=1;
    a=a+1;
}

cl var.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

var.c
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:var.exe
var.obj

Generated code:

55                           push        ebp
8BEC                         mov         ebp,esp
51                           push        ecx
C745FC00000000               mov         d,[ebp][-04],000000000
8B45FC                       mov         eax,[ebp][-04]
83C001                       add         eax,001
8945FC                       mov         [ebp][-04],eax
8B4DFC                       mov         ecx,[ebp][-04]
83C101                       add         ecx,001
894DFC                       mov         [ebp][-04],ecx
8B55FC                       mov         edx,[ebp][-04]
83C201                       add         edx,001
8955FC                       mov         [ebp][-04],edx
33C0                         xor         eax,eax
8BE5                         mov         esp,ebp
5D                           pop         ebp
C3                           retn

We have our usual prologue/epilogue, creation of a local variable by pushing ecx into the stack(only one variable :D)

and all of the increments turned into
mov         ecx,[ebp][-04]
add         ecx,001
mov         [ebp][-04],ecx
.. also note how registers are not reused( but it goes from eax,ecx,edx)

of course turning on optimizations(max /Ox):
would just give
 33C0                         xor         eax,eax
 C3                           retn
(o shi- unused variable is useless )
/O1 would remove that variable as well, /O2 as well(difference being that O1 wont generate alignment)

if i add printf("%d",a); to the code, the compiler just calculates that a = 3 and writes

6A03                         push        003       ; optimized lol
6830704000                   push        000407030 ; "%d"
E814000000                   call       .000401020 ; printf
83C408                       add         esp,008
33C0                         xor         eax,eax
C3                           retn

of course i could keep on toying with this, but there are many wonders of the c compiler, like:

    int a=0;
    a++;
    printf("%d",a);
    a+=1;
    printf("%d",a);
    a=a+1;
    printf("%d",a);

getting expanded into
6A01                         push        001
6830704000                   push        000407030  ----- (1)
E824000000                   call       .000401030  ----- (2)
6A02                         push        002
6830704000                   push        000407030  ----- (3)
E818000000                   call       .000401030  ----- (4)
6A03                         push        003
6830704000                   push        000407030  ----- (5)
E80C000000                   call       .000401030  ----- (6)
83C418                       add         esp,018 ;""
33C0                         xor         eax,eax
C3                           retn

but yet, i still dont see it using 'inc' or 'dec'




Name: Anonymous 2007-04-01 0:04 ID:Heaven

>>continuation
actually, if i give it a value the compiler doesnt know it generates this wonderful code:


51                           push        ecx
56                           push        esi
8B742404                     mov         esi,[esp][04]
46                           inc         esi
56                           push        esi
6830704000                   push        000407030  ----- (1)
E82E000000                   call       .000401040  ----- (2)
46                           inc         esi
56                           push        esi
6830704000                   push        000407030  ----- (3)
E822000000                   call       .000401040  ----- (4)
46                           inc         esi
56                           push        esi
6830704000                   push        000407030  ----- (5)
E816000000                   call       .000401040  ----- (6)
83C418                       add         esp,018 ;""
33C0                         xor         eax,eax
5E                           pop         esi
59                           pop         ecx
C3                           retn


main(int b)
{
    int a;
    a++;
    printf("%d",a);
    a+=1;
    printf("%d",a);
    a=a+1;
    printf("%d",a);
}

Name: Anonymous 2007-04-01 1:01 ID:ZoDCchC8

The default behaviour doesn't make any sense. Then again, it's MS software.

Name: Anonymous 2007-04-01 11:52 ID:p4QXrwYs

so, has anyone made an anim for this program yet?

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

fuck you asshole

Name: Anonymous 2007-04-03 10:26 ID:+9+1yvZQ

screw you bitch

Name: Anonymous 2007-04-03 10:34 ID:wQhM5Bvw

rot in hell motherfucker

Name: Anonymous 2007-04-03 11:01 ID:rRIhsgrw

>>28
>>29
>>30
r gay

Name: Anonymous 2007-04-03 17:52 ID:+9+1yvZQ

>>31 is a wannabe lesbian artfag

Name: Anonymous 2007-04-03 18:27 ID:x13er3RA

>>32
DID I HEAR LESBIAN ?????
http://www.lesbien.mine.nu

Name: Anonymous 2007-04-04 4:48 ID:6QvnN1En

Name: Anonymous 2007-04-04 7:09 ID:gjMv+C26

>>34

Problem. Link is gay.

Name: Anonymous 2007-04-04 7:13 ID:DpCpK1rx

Name: Anonymous 2007-04-04 9:15 ID:kTJEtfxv

         HOOK                FORK             CAPPED FORK

      g       g           g        g            g     g
     / \     / \         / \      / \           |     |
    y   h   x   h       f   h    f   h          h     h
        |       |       |   |   / \ / \         |    / \
        y       y       y   y   x y x y         y   x   y

Name: Anonymous 2007-04-05 11:03 ID:Gv9U/vMf


PENIS
8===B

Name: Anonymous 2007-04-05 11:55 ID:rSg+WFzf

>>38
scale 1:1

Name: Anonymous 2007-04-05 22:11 ID:Y6ZgyLOY

>>34
>polymorph.freehostia.com/sonic.txt
fix'd

Name: Anonymous 2007-04-06 7:14 ID:f8+tZP51

Name: Anonymous 2007-04-06 12:15 ID:Pwo1lTkJ

>>41
Wow, that's excruciatingly gay, why do males love sonic that much?

Name: Anonymous 2007-04-06 13:36 ID:Q1LblxqK

FASTEST THING ALIVE
SOOOONIC THE HEDGEHOG

Name: Anonymous 2007-04-06 14:30 ID:zewV5wsZ

FAST IS HOT
SLOW IS NOT

Name: Anonymous 2007-04-11 1:46 ID:mJW1wX1H

sonic is a sexy beast

Name: Yuji Naka 2007-04-11 4:56 ID:G2ZJx1bd

>>45
FUR FAGS FACK YOU

Name: Anonymous 2007-04-11 6:17 ID:Heaven

Too bad Sonic is slow as fuck.

Name: Anonymous 2007-04-11 9:43 ID:Sd+O+XVL

>>47
Y-YOU LIE !!

Name: Anonymous 2007-04-11 9:53 ID:Sd+O+XVL

………………………………………,-“¯¯……,/’ ¯”~-,;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;_,-“::/……,,,,,,,,,/”;;;;;;;;;;
…………………………………….,/…………/,::::,::::”\,;;;;;;;;,-~_,,,,__,,,,,_,,,-~”:::::/……..,,,,,,,,/;;;;;;;;;;;;
………………………………………………….”~,/:_,-~);;,,-”-~” ¯”””;;-“::::::::::::::::::/…....,,,,,,,,,/’;;;;;;;;;;;;;;
…YOUR RESISTANCE ONLY…………_,-~,…/-“¯:::/””””::::::_,_::::::::::::::::::::::::/……,,-~””¯¯;;;;;;;;;;;;;;;;
……MAKES MY PENIS HARDER…r”¯::::::¯¯:::::::::::::::::,-“::::¯¯”~--,,::::::::::::(..,,-~”\;;;;;;;;;;;;;;;;;;;;;;;;;
…………………………………………|_:::::::,:::::::::::::::::,-“:::::::::_:::::::¯:::::::::::,/”::::::::”-,;;;;;;;;;;;;;;;;;;;;
…………………………………………1/’\:::::/:::::::::::,::,-“::::::::,-“¯¯”-,:::::::::::::::’:|::::::::::::”~,;;;;;;;;;;;;;;;;;
………………………………………….1..\:::|:::::::::::/::’:::::::::,/………”\,::::::::::::::\::::::::::::::::”\;;;;;;;;;;;;;;
…………………………………………..\ I,-‘~”¯”-,_::|::::,:::::,/……….,/”:::::::::::::::::’\::::,:::::::::::”-,;;;;;;;;;;;;
………………………………………..,-~”¯:::::::::::::::\::::’\::,/...I……,-“-~”¯¯::::::::::::”\::|::::::::::::::\,;;;;;;;;;;
…………………………………._,-~”¯::::::::::::::::::|:::¯”~:`¯¯"~---~~::::::::::::::::::::::::’\:|,::::::::::::::\;;;;;;;;;
……………………….._......,-~”::::::::::::::::::::::::,/::::::::::::,--“¯::::::::::::::::::::::::::::::::|’|::::::::::::::::\;;;;;;;
…………………….,-“¯:”-~”¯::::::::::::::::::::::::_,_/”:::::::::,-*’:::::::::::::::::::::::::::::::::::::|;|:::::::::::::::::\;;;;;;
…………………..,-“.,-“”-,¯”~:::::::::::::_,,--~”¯:::::\,::::::::(:::::::::::::::::::::::::::::::::::::::::|’:1:::::::::::::::::’\;;;
………………….(,;;(|(“;;;¯”:::::::::::::::::::_,,-~’””\::::\:::::::\:::::::::::::::::::::::::::::::::::::::.|::|::::::::::::::::::::\;;
…………………..¯”\:\;;;;;;,-:::::::::::::::::¯:::::::;;;;”\:::””)::::\::::::::::::::::::::::::::::::::::::::/:::|:::::::::::::::::::::\;
………………….../”`:”~~”¯::::::::::::::::::,:::::::::,-“¯:,/’:::::_”\::::::::::::::::::::::::::::::::::::/::::|::::::::::::::::::::::`
…………………..’\:::::::::::::::::::::::::::::::”-----~”:::,/”::::-“¯¯”-\,:::::::::::::::::::::::::::::::,/’:::::|:::::::::::::::::::::::
…………………..,’)::::::::::::::::::::::::::::::::::::::::*”¯:::_,,,----,,:”\:::::::::::::::::::::::::,-*”::::::|’:::::::::::::::::::::::
………………….”-,:::::_,__:::::::::::::::::::::::::::,,--~”¯….|,,,,,):/:::::::::::::::::::::_,-“¯:::::::::/:::::::::::::::::::::::
…………………….¯”¯.|_..¯”~-,_:::::::::::_,-~”¯……_,~”,,,,/:|::,,,,-,-----------~’"¯:::::::::::::/:::::::::::::::::::::::::
…………………………..¯”~-,_..¯”~---~””|…..._,-~”¯;;;;;,/:::’::,-~”::::::::::::::::::::::::::::::/::::::::::::::::::::::::::
……………………………_,=(.¯”~-_,___,,,-~”¯.,-~””|;;,-“::,/:,/::::::::::::::::::::::::::::::::::/::::::::::::::::::::::::::::
……………………….,__,/\::--\,,,_..¯””~~-----~”¯…../-“:::,/-,*”:::::::::::::::::::::::::::::::::/::::::::::::::::::::::::::::::
……………..,---~~”””¯,,,/,,,\__::::¯”~--,,_........._,-~”::::::/”::|::::::::::::::::::::::::::::::::,/::::::::::::::::::::::::::::::,
…………….,|,,,,Poochy818,,¯\:::::~-,,_::::::::::::::::::::,/::::::\::::::::::::::::::::::::::::::/:::::::::::::::::::::::::,-~”¯,
…………._,,/,,,,,,,,,,,\.,,’\,,,,,,,,’\::::::::::¯¯”::::-~:::::::,/”::::::::`:::::::::::::::::::::::::,/:::::::::::::::::::::,-~”

Name: Anonymous 2007-04-11 13:32 ID:htD2a/Rs

>>49

HORSOME

Name: Anonymous 2007-04-11 13:32 ID:nyr+JXGw

horsecum

Name: Anonymous 2009-01-14 12:47

LISP

Name: Anonymous 2010-12-28 11:19

Name: Anonymous 2011-02-04 17:31

Name: Sgt.Kabu䖷㸍kiman燎ꠥ 2012-05-28 23:55

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

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