| #include <allegro.h> void init(); void deinit(); int main() { int x,y,i,bianco,nero,rosso,verde,blu,giallo; int xc,yc,r,xc2,yc2,r2,xc1,yc1,r1,xc3,yc3,r3; init(); bianco=0xffffff; nero=0x000000; rosso=0xff0000; blu=0x0000ff; verde=0x00ff00; giallo=0xffff00; r=2; r1=2; r2=2; r3=2; int vel=4000; textprintf_ex(screen, font, 320, 260, bianco, -1, "Left Click to reset animation"); textprintf_ex(screen, font, 340, 280, bianco, -1, "Press Esc to Exit"); for(i=1;((i>0)&&(!key[KEY_ESC]));i=i+3); clear (screen); while (!key[KEY_ESC]) { if ((mouse_b & 1)==1) { clear(screen); } x = rand() %1020 + 0; y = rand() %600 + 0; xc=x; yc=y; circlefill(screen, xc, yc, r, blu); for(i=1;i>0;i=i+vel ); x = rand() %1020 + 0; y = rand() % 600 + 0; xc1=x; yc1=y; circlefill(screen, xc1, yc1, r1, rosso); for(i=1;i>0;i=i+vel ); x = rand() %1020 + 0; y = rand() %600 + 0; xc2=x; yc2=y; circlefill(screen, xc2, yc2, r2, verde); for(i=1;i>0;i=i+vel ); x = rand() %1020 + 0; y = rand() %600 + 0; xc3=x; yc3=y; circlefill(screen, xc3, yc3, r3, giallo); for(i=1;i>0;i=i+vel ); } deinit(); return 0; } END_OF_MAIN() void init() { int depth, res; allegro_init(); depth = desktop_color_depth(); if (depth == 0) depth = 32; set_color_depth(depth); res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 1020, 600, 0, 0); if (res != 0) { allegro_message(allegro_error); exit(-1); } install_timer(); install_keyboard(); install_mouse(); }
void deinit() { clear_keybuf(); }
|