#include <allegro.h>
#define R makecol(255,0,0)
#define G makecol(0,255,0)
#define B makecol(0,0,255)
#define K makecol(0,0,0)
#define W makecol(255,255,255)
float inner_circ_angle=0;
float cx=0,cy=0;
float sx=0,sy=0;
float r=30,angle=0;//rotating circle
BITMAP *buffer;
int draw_main_circles();
int draw_rotating_circles();
int main()
{
//int cirnum=0;
//int rx=0,ry=0;//to detect the sign of directions
//int dir=0;
allegro_init();
install_keyboard();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);
buffer=create_bitmap(SCREEN_W,SCREEN_H);
cx=SCREEN_W/2;
cy=SCREEN_H/2;
//layernum=2;//one layer
while(!key[KEY_ESC])
{
draw_main_circles();
//circle(buffer,cx,cy,r,K);
//draw_rotating_circles();
blit(buffer,screen,0,0,0,0,buffer->w,buffer->h);
clear_to_color(buffer,K);
rest(100);
}
destroy_bitmap(buffer);
allegro_exit();
}END_OF_MAIN();
int draw_main_circles()
{
int i=0,j=0;
int tx=0,ty=0;
//for main circle
circle(buffer,cx,cy,r,G);
//tx=cx+r*cos(inner_circ_angle);
//ty=cy+r*sin(inner_circ_angle);
//circlefill(buffer,tx,ty,4,K);
for(j=0;j<10;j++)
{
for(i=0;i<=10;i++)
{
tx=cx+(j*r)*cos(i*36);
ty=cy+(j*r)*sin(i*36);
circle(buffer,tx,ty,r,G);
//calculating for sub circle
sx=tx+r*cos(inner_circ_angle);
sy=ty+r*sin(inner_circ_angle);
circlefill(buffer,sx,sy,3,makecol(rand()%255,rand()%255,rand()%255));
inner_circ_angle+=0.1;
}
if(j>=10) j=0;
if(inner_circ_angle>=360) inner_circ_angle=0;
}
return 1;
}//end for main-circles drawing
/*int draw_rotating_circles()
{
sx=cx+r*cos(inner_circ_angle);
sy=cy+r*sin(inner_circ_angle);
inner_circ_angle++;
circlefill(buffer,sx,sy,3,R);
blit(buffer,screen,0,0,0,0,buffer->w,buffer->h);
//inner_circ_angle++;
if(inner_circ_angle>=360)
inner_circ_angle=0;
return 1;
}*/
#define R makecol(255,0,0)
#define G makecol(0,255,0)
#define B makecol(0,0,255)
#define K makecol(0,0,0)
#define W makecol(255,255,255)
float inner_circ_angle=0;
float cx=0,cy=0;
float sx=0,sy=0;
float r=30,angle=0;//rotating circle
BITMAP *buffer;
int draw_main_circles();
int draw_rotating_circles();
int main()
{
//int cirnum=0;
//int rx=0,ry=0;//to detect the sign of directions
//int dir=0;
allegro_init();
install_keyboard();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);
buffer=create_bitmap(SCREEN_W,SCREEN_H);
cx=SCREEN_W/2;
cy=SCREEN_H/2;
//layernum=2;//one layer
while(!key[KEY_ESC])
{
draw_main_circles();
//circle(buffer,cx,cy,r,K);
//draw_rotating_circles();
blit(buffer,screen,0,0,0,0,buffer->w,buffer->h);
clear_to_color(buffer,K);
rest(100);
}
destroy_bitmap(buffer);
allegro_exit();
}END_OF_MAIN();
int draw_main_circles()
{
int i=0,j=0;
int tx=0,ty=0;
//for main circle
circle(buffer,cx,cy,r,G);
//tx=cx+r*cos(inner_circ_angle);
//ty=cy+r*sin(inner_circ_angle);
//circlefill(buffer,tx,ty,4,K);
for(j=0;j<10;j++)
{
for(i=0;i<=10;i++)
{
tx=cx+(j*r)*cos(i*36);
ty=cy+(j*r)*sin(i*36);
circle(buffer,tx,ty,r,G);
//calculating for sub circle
sx=tx+r*cos(inner_circ_angle);
sy=ty+r*sin(inner_circ_angle);
circlefill(buffer,sx,sy,3,makecol(rand()%255,rand()%255,rand()%255));
inner_circ_angle+=0.1;
}
if(j>=10) j=0;
if(inner_circ_angle>=360) inner_circ_angle=0;
}
return 1;
}//end for main-circles drawing
/*int draw_rotating_circles()
{
sx=cx+r*cos(inner_circ_angle);
sy=cy+r*sin(inner_circ_angle);
inner_circ_angle++;
circlefill(buffer,sx,sy,3,R);
blit(buffer,screen,0,0,0,0,buffer->w,buffer->h);
//inner_circ_angle++;
if(inner_circ_angle>=360)
inner_circ_angle=0;
return 1;
}*/
No comments:
Post a Comment