Tin học Game Flapy Bird cải tiến bằng Pascal

trà nguyễn hữu nghĩa

Cựu Mod Vật Lí |Cây bút Thơ|Thần tượng VH
Thành viên
14 Tháng năm 2017
3,974
7,619
744
21
Phú Yên
Trường THPT Lương Văn Chánh
[TẶNG BẠN] TRỌN BỘ Bí kíp học tốt 08 môn
Chắc suất Đại học top - Giữ chỗ ngay!!

ĐĂNG BÀI NGAY để cùng trao đổi với các thành viên siêu nhiệt tình & dễ thương trên diễn đàn.

Code đơn giản nhưng khá hay nhá.
Mình định làm theo anh @kien_coi_1997 nhưng không được, bị lỗi mới thành ra thế này
upload_2018-5-21_21-58-24.png
Mã:
 Program Flapy_Bird;
 uses crt;
 const TgRoi = 5;
       KichThuoc = 51;
       X = 30;

 var Cot: array[1..79] of integer;
     Y,Tg,diem: integer;
     k: char;
     tamdung: Boolean;

 Procedure KhoiTaoCot;
 var i, j: integer;
 Begin
      TextColor(Red);
      for i := 1 to KichThuoc - 1 do
      begin
           Cot[i] := 2 + random(18);
           for j := 25 downto 25 - Cot[i] do
           begin
                Gotoxy(i,j);
                Write(#219);
           end;
           Gotoxy(i,1);Write(#31);
      end;
      TextColor(Green);
      for i := KichThuoc to 79 do
      begin
           Gotoxy(i,1);Write(#178);
           Gotoxy(i,25);Write(#178);
      end;
      for i := 2 to 24 do
      begin
           Gotoxy(KichThuoc,i);Write(#178);
           Gotoxy(79,i);Write(#178);
      end;
 End;

 Procedure InCot;
 var i, j: integer;
 Begin
      Cot[KichThuoc] :=  2 + Random(18);
      for i := 1 to KichThuoc - 1 do
      begin
           TextColor(Red);
           if Cot[i] > Cot[i+1] then
           for j := 25 - Cot[i + 1] downto 25 - Cot[i] do
           begin
           Gotoxy(i,j);
           Write(#32);
           end
           else
           for j := 25 - Cot[i] downto 25 - Cot[i + 1] do
           begin
           Gotoxy(i,j);
           Write(#219);
           end;
           Cot[i] := Cot[i + 1];
      end;
 End;

 Procedure HuongDan;
 Begin
      TextColor(LightRed);
      Gotoxy(KichThuoc + (79 - KichThuoc) div 2 - 5,3);
      Write('FLAPY');
      TextColor(Blue);
      Write(' BIRD');
      TextColor(Blue);
      Gotoxy(KichThuoc + 2,8);
      Write('Huong Dan: ');
      TextColor(Yellow);
      Gotoxy(KichThuoc + 2,9);
      Write('Bam phim bat ky de nhay.');
      Gotoxy(KichThuoc + 2,10);
      Write('Khi vao cham vao cac cot');
      Gotoxy(KichThuoc + 2,11);
      Write('hoac gai thi ban se thua.');
      Gotoxy(KichThuoc + 2,12);
      TextColor(Red);
      Write('Bam "p" de tam dung.');
 End;

 Procedure KetThuc;
 Begin
      TextColor(White);
      if Y >= 1 then
      Gotoxy(X,Y)
      else Gotoxy(X,1);
      Write(#1);
      Gotoxy(KichThuoc div 2 - 6,10);
      Write('Ban thua rui!');
      Gotoxy(KichThuoc div 2 - 14,12);
      TextColor(White + Blink);
      Write('Bam phim Enter de thoat...');
      repeat until readkey = #13;
 End;

 BEGIN
      TextBackGround(Black);
      clrscr;
      KhoiTaoCot;
      HuongDan;
      Y := 4;
      Tg := 0;
      Diem := 0;
      tamdung := False;
      TextColor(White);
      Gotoxy(X,Y);Write(#1);
      repeat
      if not tamdung then
      InCot;
      if k <> #0 then k := #0;
      if (Tg >= TgRoi) and (not tamdung) then
      begin
           TextColor(White);
           Gotoxy(X,Y);Write(#32);
           Y := Y + 1;
           Gotoxy(X,Y);Write(#1);
           tg := 0;
           inc(Diem);
      end;
      if not tamdung then
      Inc(Tg);
      if Keypressed then k := readkey;
      if k = 'p' then
      begin
           tamdung := not tamdung;
           Gotoxy(Kichthuoc + 2,15);
           TextColor(LightRed + Blink);
           if tamdung = True then
           Write('Bam "p" de tiep tuc!')
           else
           Write('                    ');
      end;
      if (k <> #0) and (not tamdung) and (k <>'p') then
      begin
      TextColor(White);
      Gotoxy(X,Y);Write(#32);
      Y := Y - 2;
      Gotoxy(X,Y);Write(#1);
      end;
      TextColor(White);
      Gotoxy(KichThuoc + 2,5);Write('Diem: ',Diem);
      until (Y  <= 1) or (Y >= 25 - Cot[X]) or (k = #27);
      if k <> #27 then
      KetThuc;
 END.
 

Ocmaxcute

Học sinh chăm học
Thành viên
13 Tháng chín 2017
801
881
146
20
Nghệ An
Bạn có chương trình game trên pas nào nx không cho mk xin vs
 
Top Bottom