Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

check out this cool pascal screen saver.. and help me improve it,

viv.viv. Posts: 72Member

[
PROGRAM ssver3;
USES crt,graph;
VAR
count,ran,n,radius,Gd, Gm: Integer;
BEGIN
gd:=Detect;
InitGraph(Gd, Gm, '');
IF GraphResult <> grOk THEN halt(1);
n:=1;
REPEAT
n:=RANDOM(getmaxx);
cleardevice;
count:=0;
BEGIN
FOR radius:=1 TO n DO
BEGIN
Circle(0,0, Radius);
Circle(getmaxx,getmaxy,radius);
Circle(trunc(getmaxx/2),trunc(getmaxy/2),radius);
Circle(getmaxx,0,radius);
Circle(0,getmaxy,radius);
line(0,getmaxy,getmaxx,0);
line(0,0,getmaxx,getmaxy);
line(0,0,getmaxx,0);
line(0,0,0,getmaxy);
line(getmaxx,getmaxy,getmaxx,0);
line(getmaxx,getmaxy,0,getmaxy);
sound(radius);
setcolor(random(128));
delay(500); {here might have to change proportionally to the speed of the comp.}
END;
END;
UNTIL keypressed;
count:=0;
cleardevice;
REPEAT
BEGIN
settextstyle(4,0,4);
setcolor(random(32));
outtextxy(0,trunc(getmaxy/2),'This program was made by Vivek Maharajh.');
count:=count+1;
END;
UNTIL count=300; {here might have to change proportionally to the speed of the comp.}
nosound;
END.
{If anyonne reads tis program, and knows how to reset the keypressed, let me know plz.}
]



Comments

  • ibyiby Posts: 323Member
    :
    : [
    : PROGRAM ssver3;
    : USES crt,graph;
    : VAR
    : count,ran,n,radius,Gd, Gm: Integer;
    : BEGIN
    : gd:=Detect;
    : InitGraph(Gd, Gm, '');
    : IF GraphResult <> grOk THEN halt(1);
    : n:=1;
    : REPEAT
    : n:=RANDOM(getmaxx);
    : cleardevice;
    : count:=0;
    : BEGIN
    : FOR radius:=1 TO n DO
    : BEGIN
    : Circle(0,0, Radius);
    : Circle(getmaxx,getmaxy,radius);
    : Circle(trunc(getmaxx/2),trunc(getmaxy/2),radius);
    : Circle(getmaxx,0,radius);
    : Circle(0,getmaxy,radius);
    : line(0,getmaxy,getmaxx,0);
    : line(0,0,getmaxx,getmaxy);
    : line(0,0,getmaxx,0);
    : line(0,0,0,getmaxy);
    : line(getmaxx,getmaxy,getmaxx,0);
    : line(getmaxx,getmaxy,0,getmaxy);
    : sound(radius);
    : setcolor(random(128));
    : delay(500); {here might have to change proportionally to the speed of the comp.}
    : END;
    : END;
    : UNTIL keypressed;
    : count:=0;
    : cleardevice;
    : REPEAT
    : BEGIN
    : settextstyle(4,0,4);
    : setcolor(random(32));
    : outtextxy(0,trunc(getmaxy/2),'This program was made by Vivek Maharajh.');
    : count:=count+1;
    : END;
    : UNTIL count=300; {here might have to change proportionally to the speed of the comp.}
    : nosound;
    : END.
    : {If anyonne reads tis program, and knows how to reset the keypressed, let me know plz.}
    : ]
    :
    :
    :
    :


    Just read the pressed key into a variable. That would reset it.
    Better keep doing it until keyboard buffer is empty:
    [code]
    var ch:char;

    while keypressed do ch:=readkey;
    [/code]

    Iby

Sign In or Register to comment.