Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //WARNING: need additional files, can not run this program alone
- // you can find it in my site :)
- // flap flap
- // full file here :http://upfile.vn/uVjCu~XtxdFQ/flappy-bird-rar.html
- program project_flapy;
- uses crt;
- label loop;
- type int = integer;
- var obj : string;
- f : text;
- x,y,n,score: int;
- kt,coin : boolean;
- col : array[1..9] of record
- diadiem,dodai: int;
- end;
- bl : array[1..80,1..25]of shortint;
- ghost : shortint;
- increase,material : int;
- k : char;
- procedure readf;
- var c : int;
- begin
- assign(f,'data.dat'); reset(f);
- obj:='';
- while not eof(f) do
- begin
- read(f,c);
- obj:=obj+chr(c);
- end;
- close(f);
- fillchar(bl,sizeof(bl),0);
- end;
- procedure drawrectangle(x,y:int; x1,y1:int; co1,co2:int);
- var i,j : int; //x1 la ngang dai y1 la doc
- c : char;
- begin
- c:=chr(material); textcolor(co1);
- gotoxy(x,y); bl[x,y]:=ghost;
- for i:=1 to x1-1 do begin bl[x+i,y]:=ghost; write(c);end;
- for j:=1 to y1-1 do begin gotoxy(x,y+j); bl[x,y+j]:=ghost; write(c); end;
- for j:=1 to y1 do begin gotoxy(x+x1-1,y+j-1); bl[x+x1-1,y+j-1]:=ghost; write(c); end;
- gotoxy(x,y+y1-1);
- bl[x,y+y1-1]:=ghost;
- for i:=1 to x1 do begin if i<>x1 then bl[x+i,y+y1-1]:=ghost; write(c); end;
- textcolor(co2);
- end;
- procedure del(re:int);
- var i:int;
- begin
- textcolor(7); textbackground(7);
- for i:=1 to 3 do write(chr(176));
- textcolor(re);
- end;
- procedure delcol(i:int);
- begin
- textcolor(7); textbackground(7);
- drawrectangle(col[i].diadiem,1,15,col[i].dodai,7,19);
- drawrectangle(col[i].diadiem,col[i].dodai+7,15,26-col[i].dodai-7,7,19);
- end;
- procedure print(re:int);
- var i : int;
- begin
- textcolor(green); write(obj[1]);
- textbackground(green); write(obj[2]);
- textcolor(black);
- gotoxy(wherex-1,wherey); write(obj[4]);
- textbackground(7);
- textcolor(yellow); write(obj[3]);
- textcolor(re);
- end;
- procedure fill(co1,co2:int);
- var i,j : int;
- c : char;
- begin
- textcolor(co1); textbackground(co1);
- for i:=1 to 25 do
- for j:=1 to 80 do write(c);
- textcolor(co2);
- end;
- procedure tree(x:int; co1,co2:int);
- var c:char; h,i:int;
- begin
- randomize;
- textcolor(co1); c:=chr(219);
- repeat
- h:=random(6)+1;
- until (h>3);
- for i:=0 to h-1 do begin gotoxy(x,23-i); write(c); end;
- c:=chr(178);
- textcolor(co2);
- gotoxy(x-2,24-h); for i:=1 to 5 do write(c);
- gotoxy(x-1,23-h); for i:=1 to 3 do write(c);
- gotoxy(x-1,25-h); write(c);
- gotoxy(x+1,25-h); write(c);
- end;
- procedure cloud(x,y:int);
- var i,j:int; c:char;
- l1,l2,l3:int;
- begin
- randomize;
- repeat
- l1:=random(4)+1;
- l2:=random(6)+1;
- l3:=random(5)+1;
- until (l1>3)and(l2>l3)and(l3>3);
- textcolor(19);
- c:=chr(176);
- gotoxy(x+3,y); for i:=1 to l1 do write(c);
- c:=chr(177);
- gotoxy(x,y+1); for i:=1 to l2 do write(c);
- c:=chr(178);
- gotoxy(x+2,y+2); for i:=1 to l3 do write(c);
- end;
- procedure pipe(x:int);
- var h1, w1, s, h2:int;
- begin
- randomize;
- repeat
- h1:=random(15)+1;
- until h1>6;
- col[n].dodai:=h1;
- w1:=15; col[n].diadiem:=x;
- material:=219;
- drawrectangle(x,1,w1,h1,18,1);
- h2:=h1+7;
- drawrectangle(x,h2,w1,25-h2+1,18,1);
- material:=178;
- end;
- procedure flap1(var x,y:int);
- var i,j:int; k:char;
- begin
- readkey;
- while (y<23)and(x<76)and(y>1)and(bl[x,y]<>1)and(bl[x+1,y]<>1)and(bl[x+2,y]<>1)and(kt)do
- begin
- gotoxy(x,y); print(3); delay(150); gotoxy(x,y); del(3);
- inc(y); inc(x);
- if (keypressed) then
- begin
- for j:=1 to 3 do
- begin
- gotoxy(x,y); print(3); delay(50); gotoxy(x,y); del(3);
- if( (x in[16..31])or(x in[39..54])or(x in[61..76]) )and(coin=false)then
- begin
- inc(increase); textcolor(0);
- gotoxy(2,2); write(increase);
- coin:=true;
- end;
- if (x in[1..15])or(x in[32..38])or(x in[55..60])or(x in[77..80]) then coin:=false;
- if (bl[x,y]=1)or(bl[x+1,y]=1)or(bl[x+2,y]=1)
- then begin kt:=false; exit; end;
- dec(y); inc(x);
- end;
- if kt then flap1(x,y);
- end;
- end;
- end;
- procedure menu;
- var i,j : int;
- c : char;
- begin
- fill(7,1); material:=178;
- drawrectangle(33,1,14,3,19,96);
- gotoxy(38,2); write('MENU');
- assign(f,'menu.dat'); reset(f);
- c:=chr(177);
- textcolor(6);
- repeat
- readln(f,i,j); gotoxy(i,j); write(c);
- until eof(f);
- close(f);
- assign(f,'sc.dat'); reset(f);
- readln(f,score);
- close(f);
- drawrectangle(65,13,13,4,4,96);
- gotoxy(66,14); write('Press space');
- drawrectangle(65,18,13,4,4,96);
- gotoxy(66,19); write('High score:');
- gotoxy(66,20); write(score);
- drawrectangle(66,23,11,3,19,0);
- gotoxy(67,24);write('LQRD team'); gotoxy(1,1);
- // // //
- repeat k:=readkey; until (k=' ')or(k=#27);
- end;
- procedure loser;
- var k:char;
- begin
- //fill(19,0);
- drawrectangle(35,12,13,5,12,0);
- gotoxy(37,14); write('YOU LOSE !');
- repeat k:=readkey; until k=' ';
- end;
- procedure play;
- var i, j : int; c:char;
- begin
- fill(7,1);
- textcolor(4); textbackground(4); gotoxy(1,25);
- for i:=1 to 80 do write('c');
- gotoxy(1,23);
- c:=chr(178);
- textcolor(6); textbackground(7);
- for i:=1 to 80 do write(c);
- material:=177;
- drawrectangle(1,1,7,3,19,0);
- for i:=10 to 70 do if i mod 10=0 then cloud(i,1);
- n:=1; ghost:=1; increase:=0; coin:=false;
- kt:=true; //U are alife;
- while kt do
- begin
- x:=1; y:=15; gotoxy(x,y); print(19);
- for i:=10 to 70 do if i mod 10=0 then tree(i,127,18);
- pipe(16);inc(n); pipe(39);inc(n); pipe(61);
- flap1(x,y);
- if (y=25) or(y<=2)or(x<76) then begin kt:=false; ghost:=0; loser; end;
- for i:=10 to 70 do if i mod 10=0 then tree(i,7,7);
- ghost:=0; delcol(1); delcol(2); delcol(3); n:=1; ghost:=1; n:=1;
- end;
- if increase>=score then
- begin
- assign(f,'sc.dat'); rewrite(f);
- write(f,increase);
- close(f);
- end;
- end;
- procedure loading;
- var i: int;
- begin
- fill(4,0);
- material:=219;
- drawrectangle(13,12,56,3,6,0);
- gotoxy(14,13);
- textcolor(3);
- for i:=1 to 54 do begin
- write(chr(178));
- if i mod 3=0 then delay(100);
- end;
- end;
- begin
- clrscr;
- readf;
- repeat
- gotoxy(1,1); ghost:=0;
- menu;
- if k<>#27 then begin
- gotoxy(1,1);
- loading;
- gotoxy(1,1);
- play;
- end;
- until k=#27;
- // encrypt
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement