Terms of Agreement:   

By using this code, you agree to the following terms...   

1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.   

2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   

3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 

4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.  

//**************************************

//     

// Name: Animacion b¨¢sica

// Description:For teching users to make

//     an animation on C++

// By: Juan Andr¨¦s Arias

//

// Assumes:Object Oriented Programming

//

// Side Effects:It may hang

//

//This code is copyrighted and has// limited warranties.Please see http://

//     www.1CPlusPlusStreet.com/xq/ASP/txtCodeI

//     d.1659/lngWId.3/qx/vb/scripts/ShowCode.h

//     tm//for details.//**************************************

//     

#include 

#include 

#include 

#include 

#include 

#include 

void dibujar(int angulo);

void *llanta[20];

    class rueda{

     int x,y,intervalo,demora,cual;

    public:

     void nueva(int nx,int ny);

     void animar();

     void vivir();

};

    void rueda::nueva(int nx,int ny){

     x=nx;

     y=ny;

     intervalo=5;

     demora=0;

     cual=0;

     putimage(x,y,llanta[cual],XOR_PUT);

};

    void rueda::vivir(){

     x--;

     animar();

     if(x<30)x=550;

};

    void rueda::animar(){

     putimage(x+1,y,llanta[cual],XOR_PUT);

     demora++;

         if(demora>=intervalo){

         demora=0;

         cual++;

         if(cual>=20)cual=0;

         };

         putimage(x,y,llanta[cual],XOR_PUT);

    };

        void dibujar(int angulo){

         angulo*=18;

         double an=angulo*3.14/180;

         circle(100,100,20);

         line(100+20*sin(an),100+20*cos(an),100-20*sin(an),100-20*cos(an));

    };

        void main(){

         unsigned int size;

         while(kbhit())getch;

         int i;

         int gdriver = DETECT, gmode, errorcode;

         initgraph(&gdriver, &gmode, "..\\bgi");

         errorcode = graphresult();

         if (errorcode != grOk) /* an error occurred */

             {

             cprintf("Graphics error: %s\n", grapherrormsg(errorcode));

             cprintf("Press any key to halt:");

             getch();

             };

             size=imagesize(80,80,121,120);

             setcolor(YELLOW);

                 for(i=0;i<20;i++){

                 dibujar(i);

                 llanta[i]=farmalloc(size);

                 getimage(80,80,121,120,llanta[i]);

                 cleardevice();

                 };

                 outtext("YA...");

                 rueda *prueba;

                 prueba=new rueda[3];

                 prueba[0].nueva(420,200);

                 prueba[1].nueva(400,200);

                 prueba[2].nueva(320,200);

                 for(i=0;i<20;i++)prueba[2].vivir();

                     while(!kbhit()){

                     prueba[0].vivir();

                     prueba[1].vivir();

                     prueba[2].vivir();

                    // delay(50);

                     };

                     getch();

                     closegraph();

                };