Bigger

Saturday, 8 November 2014

How to make screensaver in c programming

Just Run it to see the magic....
-------------------------------------------------------------------------------------------------------------
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
int main()
{
clrscr();
randomize();
float ballx=rand()%76+2,bally=rand()%20+2;
float velx=1,vely=1;
int i=0;
while(!kbhit())
{
i++;
textcolor(i);
delay(100);
clrscr();
if(1)
{
if(ballx<2)
velx=-velx;
else if(ballx>78)
velx=-velx;
}
if(1)
{
if(bally<=1)
vely=-vely;
else if(bally>=23)
vely=-vely;

}
ballx+=velx;
bally+=vely;
gotoxy(ballx,bally);
cprintf("SofTecH");
}
getch();
return 0;
}

------------------------------------------------------------------------------------------------
Note:-This program will exclusively run in dosbox.... 

output:-
Moving and name and get reflected back on striking the end of screen

If you want the video clip of it's output then just put a mail to me....


No comments:

Post a Comment