Home - qdidactic.com
Didactica si proiecte didacticeBani si dezvoltarea cariereiStiinta  si proiecte tehniceIstorie si biografiiSanatate si medicinaDezvoltare personala
referate stiintaSa fii al doilea inseamna sa fii primul care pierde - Ayrton Senna





Aeronautica Comunicatii Drept Informatica Nutritie Sociologie
Tehnica mecanica

C


Qdidactic » stiinta & tehnica » informatica » c
Program de joc demonstrativ in C - 'Sarpele' culegator de numere



Program de joc demonstrativ in C - 'Sarpele' culegator de numere


Program Sarpe;


Uses Crt;

Const

sc=#219;

lungmax=95;

maxnext=10;

xlimit=[1,80];

ylimit=[1,25];

Var

sx,sy:array[1..95] of byte;

c:char;

i,primul,ultimul,next,tdelay,idelay:integer;

xnext,ynext:byte;

Begin

clrscr;

randomize;

for i:=1 to 79 do begin gotoxy(i,1);write(sc);gotoxy(i,25);write(sc);end;

for i:=1 to 24 do begin gotoxy(1,i);write(sc);gotoxy(80,i);write(sc);end;

primul:=2;ultimul:=1;

for i:=primul downto ultimul do begin sx[i]:=40;sy[i]:=13;end;

next:=0;idelay:=100;

for i:=primul downto ultimul do begin

gotoxy(sx[i],sy[i]);write(sc);

end;

c:=readkey;

while next<maxnext do

begin

xnext:=2+random(78);ynext:=2+random(23);

inc(next);gotoxy(xnext,ynext);write(next);

repeat

if keypressed then begin

c:=readkey;tdelay:=idelay;

if c=#0 then c:=readkey;

end

else tdelay:=tdelay*97 div 100;

case c of

'1'..'9':

idelay:=100+100 div (ord(c)-ord('1')+1);

#75:

begin

gotoxy(sx[ultimul],sy[ultimul]);write(' ');

if primul=lungmax then begin

sx[1]:=sx[primul]-1;sy[1]:=sy[primul];

primul:=1

end

else begin

inc(primul);

sx[primul]:=sx[primul-1]-1;sy[primul]:=sy[primul-1];

end;

if ultimul=lungmax then ultimul:=1

else inc(ultimul);

end;

#77:

begin

gotoxy(sx[ultimul],sy[ultimul]);write(' ');

if primul=lungmax then begin

sx[1]:=sx[primul]+1;sy[1]:=sy[primul];

primul:=1

end

else begin

inc(primul);

sx[primul]:=sx[primul-1]+1;sy[primul]:=sy[primul-1];

end;

if ultimul=lungmax then ultimul:=1

else inc(ultimul);

end;

#72:

begin

gotoxy(sx[ultimul],sy[ultimul]);write(' ');



if primul=lungmax then begin

sx[1]:=sx[primul];sy[1]:=sy[primul]-1;

primul:=1

end

else begin

inc(primul);

sx[primul]:=sx[primul-1];sy[primul]:=sy[primul-1]-1;

end;

if ultimul=lungmax then ultimul:=1

else inc(ultimul);

end;

#80:

begin

gotoxy(sx[ultimul],sy[ultimul]);write(' ');

if primul=lungmax then begin

sx[1]:=sx[primul];sy[1]:=sy[primul]+1;

primul:=1

end

else begin

inc(primul);

sx[primul]:=sx[primul-1];sy[primul]:=sy[primul-1]+1;

end;

if ultimul=lungmax then ultimul:=1

else inc(ultimul);

end;

end;

if primul > ultimul then

for i:=primul downto ultimul do begin

gotoxy(sx[i],sy[i]);write(sc);

if (sx[primul]=sx[i]) and (sy[primul]=sy[i]) and (i<>primul) then

c:=#27;

end

else

begin

for i:=ultimul to lungmax do begin

gotoxy(sx[i],sy[i]);write(sc);

if (sx[primul]=sx[i]) and (sy[primul]=sy[i]) and (i<>primul) then

c:=#27;

end;

for i:=1 to primul do begin

gotoxy(sx[i],sy[i]);write(sc);

if (sx[primul]=sx[i]) and (sy[primul]=sy[i]) and (i<>primul) then

c:=#27;

end;

end;

if (sx[primul] in xlimit)or(sy[primul] in ylimit) then c:=#27;

delay(tdelay);

until (c=#27) or ((sx[primul]=xnext)and(sy[primul]=ynext));

sound(next*30);

if c=#27 then next:=maxnext

else

if ultimul-next <= 0 then begin

for i:=lungmax+ultimul-next to lungmax do begin

sx[i]:=sx[ultimul];sy[i]:=sy[ultimul];

end;

for i:=1 to ultimul do begin

sx[i]:=sx[ultimul];sy[i]:=sy[ultimul];

end;

ultimul:=lungmax+ultimul-next;

end

else begin

for i:=ultimul-next to ultimul do begin

sx[i]:=sx[ultimul];sy[i]:=sy[ultimul];

end;

ultimul:=ultimul-next;

end;

delay(tdelay);

nosound;

end;

End.




Contact |- ia legatura cu noi -| contact
Adauga document |- pune-ti documente online -| adauga-document
Termeni & conditii de utilizare |- politica de cookies si de confidentialitate -| termeni
Copyright © |- 2024 - Toate drepturile rezervate -| copyright