03-10-2003, 12:27 AM
I've remade my qbasic 9-line-screensaver
in c++ with allegro (not 9 lines anymore...):
in c++ with allegro (not 9 lines anymore...):
Code:
#include "allegro.h"
int main()
{
PALETTE palette;
int c,x,y;
srand(time(NULL));
allegro_init();
install_keyboard();
set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 320, 200, 0, 0);
set_display_switch_mode(SWITCH_PAUSE);
for (c=0; c<32; c++)
{
palette[c].r = 0;
palette[c].g = c;
palette[c].b = 0;
palette[63-c].r = 0;
palette[63-c].g = c;
palette[63-c].b = 0;
}
set_palette(palette);
while (!keypressed())
{
x=(rand()%32)*10;
y=(rand()%20)*10;
acquire_screen();
c=getpixel(screen,x,y);
if(c==63)
{
c=0;
}
else
{
c++;
}
rect(screen, x, y, x+9, y+9, c);
release_screen();
}
remove_keyboard();
return 0;
}
END_OF_MAIN();