Wednesday, 28 August 2013

allegro game programming circle animations

#include<allegro.h>
BITMAP *buffer;
double radius=0;
int r=0,b=0,g=0;
int i=0;
int cx=0,cy=0;
int main()
{
    allegro_init();
    install_keyboard();
    set_color_depth(32);
    set_gfx_mode(GFX_AUTODETECT_WINDOWED,1200,700,0,0);
    srand(time(NULL));
    buffer=create_bitmap(SCREEN_W,SCREEN_H);
    srand(time(NULL));

                                         while((!key[KEY_ESC]))
                                         {
                                                             clear_bitmap(buffer);
                                                             cx=rand()%(SCREEN_W-100);
                                                             cy=rand()%(SCREEN_H-100);
                                                             radius=0;
                                                                 for(i=0;i<50;i++)
                                                                 {
                                                                 radius+=rand()%2;
                                                                  r=rand()%255;
                                                                  g=rand()%200+25;
                                                                  b=rand()%100+150;
                                                                  circle(buffer,cx,cy,radius,makecol(r,g,b));
                                                                  blit(buffer,screen,0,0,0,0,buffer->w,buffer->h);
                                                                  rest(4);
                                                                  }
                                                                      
                                                                       }
                                                                       //readkey();
                                                                       destroy_bitmap(buffer);
                                                                       }END_OF_MAIN();             

No comments:

Post a Comment