Counter Strike o'yini PascalABC tilida #birinchidasturlashtili 

Bundan 2 yil oldin  9-sinf informatika kitobdan Turbo Pascal dasturlash tilini o'rgandim va PascalABC muhitida ishlashni boshladim. Dasturlashda asosiy meni qiziqtiradigan narsa o'yin yaratish edi. Har bir o'rgangan statementlardan o'yin yaratishda foydalanardim shuning uchun bo'lsa kerak ko'plari esimda qolgan. Mana bu yerda 108 qator koddan iborat men yaratgan Counter Strike o'yini

https://youtu.be/NwACc71sNFE

 

O'yin kodlari:

Uses crt;

label takrc, tamomc;
var
  yunalc: string; 
  winnerc,ustc,satc,x0c,y0c,x1c,y1c,res1,res2,knifex1,knifey1,knifex2,knifey2,bombx1,bomby1,bombx2,bomby2: byte;
  xcon1, ycon1, xcon2, ycon2: array [1..10] of byte;
  log1,log2: array[1..10] of boolean;
  knife1,knife2,bomb1,bomb2 : boolean;
  Comp:array [0..9] of char;

{x0c, y0c, x0c, y0c - smayliklar koordinatasi
 res1, res2 - o`qlar soni
 xcon1, ycon1, xcon2, ycon2 - o`qlar koordinatasi
 yunal - yo`nalish klavishi
 winner - agar 1-o`yinchi bo`lsa=1, aks holda 2
 knifex1, knifey1, knifex2, knifey2 - pichoq koordinata
 knife1,knife2 - pichoq bor yoki yo`q
 bomb1, bomb2 - bomba bor yoki yo`q
 bombx1, bomby1, bombx2, bomby2 - bomba koordinata
 Comp - kompyuter yurish yo`llari
}
begin
  {Counter Boshlan}
  randomize;
  x0c := 3; y0c := 11; x1c := 78; y1c := 11; res1 := 0; res2 := 0;
  bomb1:=true; bomb2:=true;
  bombx1:=Random(38)+41; bomby1:=Random(19)+2; 
  bombx2:=Random(37)+2; bomby2:=Random(19)+2;
  Comp[0]:='8'; Comp[1]:='4'; Comp[2]:='5'; Comp[3]:='6'; Comp[4]:='7';
  Comp[5]:='9'; Comp[6]:='/'; Comp[7]:='*'; Comp[8]:='-'; Comp[9]:='+';
  
  takrc: 
  
  {O`qlar soni} 
  clrscr; knife1:=false; knife2:=false;
  knifex2:=0; knifey2:=0; knifex1:=0; knifey1:=0;
  textcolor(14); Gotoxy(2,24); write(chr(26),' ',10-res1);
  Gotoxy(12,24); write(chr(15),' '); if bomb1 then write(1) else write(0);
  GotoXY(67, 24); textcolor(10); if bomb2 then write(1) else write(0); write(' ',chr(15));
  GotoXY(76, 24); write(10-res2,' ',chr(27));
  
  {Dizayn}
  for satc := 1 to 80 do begin if satc div 41=0 then textcolor(14) else textcolor(10); GotoXY(satc, 22); Write('_'); end;
  textcolor(red); GotoXY(40, 22); Write('_');
  
    {1-o`yinchi}
  if keypressed then begin
    yunalc := readkey; textcolor(14);
    if (yunalc = 'd') and (x0c + 1 < 80) then x0c := x0c + 1 else if (yunalc = 'd') and (x0c + 1 > 79) then x0c := 79;   {o`ng}
    if (yunalc = 'a') and (x0c - 1 > 1) then x0c := x0c - 1 else if (yunalc = 'a') and (x0c - 1 < 2) then x0c := 2;      {chap}
    if (yunalc = 's') and (y0c + 1 < 22) then y0c := y0c + 1 else if (yunalc = 's') and (y0c + 1 > 21) then y0c := 21;   {past}
    if (yunalc = 'w') and (y0c - 1 > 1) then y0c := y0c - 1 else if (yunalc = 'w') and (y0c - 1 < 2) then y0c := 2;      {tepa}
    if (yunalc = 'e') and (res1+1<=10) then begin res1:=res1+1; log1[res1]:=True; xcon1[res1]:=x0c+1; ycon1[res1]:=y0c; {o`q}
    GotoXY(x0c+1,y0c); textcolor(yellow); write(chr(26)); end;
    if (yunalc = 't') then begin knife1:=true; knifex1:=x0c; knifey1:=y0c-1; GotoXY(knifex1,knifey1); write(chr(24)); end; {tepa pichoq}
    if (yunalc = 'f') then begin knife1:=true; knifex1:=x0c-1; knifey1:=y0c; GotoXY(knifex1,knifey1); write(chr(27)); end; {chap pichoq}
    if (yunalc = 'h') then begin knife1:=true; knifex1:=x0c+1; knifey1:=y0c; GotoXY(knifex1,knifey1); write(chr(26)); end; {o`ng pichoq}
    if (yunalc = 'g') then begin knife1:=true; knifex1:=x0c; knifey1:=y0c+1; GotoXY(knifex1,knifey1); write(chr(25)); end; {past pichoq}
    
    if (yunalc = 'r') and (bomb1) then begin bomb1:=false; for ustc:=bombx1-2 to bombx1+2 do for satc:=bomby1-2 to bomby1+2 do begin Gotoxy(ustc,satc); write(chr(15)) end;
    if ((bombx1-2)<=x1c) and ((bombx1+2)>=x1c) and ((bomby1-2)<=y1c) and ((bomby1+2)>=y1c) then begin winnerc:=1; goto tamomc; end; {bomba}
    end; end;
    
    yunalc:=Comp[random(10)];
    {2-o`yinchi} textcolor(10);
    if (yunalc = '6') and (x1c + 1 < 80) then x1c := x1c + 1 else if (yunalc = '6') and (x1c + 1 > 79) then x1c := 79;   {o`ng}
    if (yunalc = '4') and (x1c - 1 > 1) then x1c := x1c - 1 else if (yunalc = '4') and (x1c - 1 < 2) then x1c := 2;      {chap}
    if (yunalc = '5') and (y1c + 1 < 22) then y1c := y1c + 1 else if (yunalc = '2') and (y1c + 1 > 21) then y1c := 21;   {past}
    if (yunalc = '8') and (y1c - 1 > 1) then y1c := y1c - 1 else if (yunalc = '8') and (y1c - 1 < 2) then y1c := 2;      {tepa}
    if (yunalc = '7') and (res2+1<=10) then begin res2:=res2+1; log2[res2]:=True; xcon2[res2]:=x1c-1; ycon2[res2]:=y1c; {o`q}
    end;
    if (yunalc = '-') then begin knife1:=true; knifex2:=x1c; knifey2:=y1c-1; GotoXY(knifex2,knifey2); write(chr(24)); end; {tepa pichoq}
    if (yunalc = '/') then begin knife1:=true; knifex2:=x1c-1; knifey2:=y1c; GotoXY(knifex2,knifey2); write(chr(27)); end; {chap pichoq}
    if (yunalc = '*') then begin knife1:=true; knifex2:=x1c+1; knifey2:=y1c; GotoXY(knifex2,knifey2); write(chr(26)); end; {o`ng pichoq}
    if (yunalc = '+') then begin knife1:=true; knifex2:=x1c; knifey2:=y1c+1; GotoXY(knifex2,knifey2); write(chr(25)); end; {past pichoq}
    
    if (yunalc = '9') and (bomb2) then begin bomb2:=false; for ustc:=bombx2-2 to bombx2+2 do for satc:=bomby2-2 to bomby2+2 do begin Gotoxy(ustc,satc); write(chr(15)) end;
    if ((bombx2-2)<=x0c) and ((bombx2+2)>=x0c) and ((bomby2-2)<=y0c) and ((bomby2+2)>=y0c) then begin winnerc:=2; goto tamomc; end; {bomba}
    end;
    
  
  {****Asosiy****}
  For ustc:=1 to 10 do begin
  if log1[ustc] then begin textcolor(yellow);if xcon1[ustc]<79 then begin Gotoxy(xcon1[ustc],ycon1[ustc]); xcon1[ustc]:=xcon1[ustc]+1; Write(chr(26)); end 
   else log1[ustc]:=False; end;
  if log2[ustc] then begin textcolor(10);if xcon2[ustc]>2 then begin Gotoxy(xcon2[ustc],ycon2[ustc]); xcon2[ustc]:=xcon2[ustc]-1; Write(chr(27)); end 
   else log2[ustc]:=False; end;
  end;
  
  {Yutish}
  for ustc := 1 to 10 do begin if ((xcon2[ustc] = x0c) or (xcon2[ustc]-1 = x0c)) and (ycon2[ustc] = y0c) or (x0c=knifex2) and (y0c=knifey2) then begin
  textcolor(10); gotoxy(x1c, y1c); Write(chr(2)); winnerc:=2; goto tamomc; end;
  if ((xcon1[ustc] = x1c) or (xcon1[ustc]+1 = x1c)) and (ycon1[ustc] = y1c) or (x1c=knifex1) and (y1c=knifey1)  then begin 
  textcolor(yellow); gotoxy(x0c, y0c); Write(chr(1)); winnerc:=1; goto tamomc; end;end;
  
  {Smayliklar}
  textcolor(yellow); gotoxy(x0c, y0c); Write(chr(1));
  textcolor(10); gotoxy(x1c, y1c); Write(chr(2));
  
  {Vaqt}
  delay(80);
  
  goto takrc;
  tamomc: delay(1500); clrscr;  if winnerc=1 then begin  Gotoxy(10, 12); textcolor(yellow); Writeln(chr(1),' Tabriklaymiz, Chap tomondagi ishtirokchi, siz, yutdingiz!!! ',chr(1)); end; 
  if winnerc=2 then begin  Gotoxy(11, 12); textcolor(10); Writeln(chr(2),' Tabriklaymiz, O`ng tomondagi ishtirokchi, siz, yutdingiz!!! ',chr(2)); end; 
  readln;{Counter Tamom}
end.