Wednesday, July 20, 2011

build your own screen saver in c++

today i will show you something interesting,its not hard to code but i am just building it for fun.
today i will code a screensaver in c++ using graphics.
it simple and easy to understand
demo executable+ source-code
#include<graphics.h> #include<stdlib.h> #include<stdio.h> #include<conio.h> #include<time.h>
int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int maxx,maxy,x,y,color,maxcolor; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, "bgi"); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* terminate with an error code */ } maxcolor=getmaxcolor()+1; maxx=getmaxx()+1; maxy=getmaxy()+1; randomize(); while(!kbhit()) { color=random(maxcolor); x=random(maxx); y=random(maxy); putpixel(x,y,color); } /* clean up */ closegraph(); return 0; }
please leave comment..
please give me new ideas.you ideas will be appreciated.
soon i will return with a new art.till then,good bye.

Labels: , , , , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home