IPB
ЛогинПароль:

> Игра "Змейка" !
сообщение
Сообщение #1


Гость






uses crt,graph;
const
x='x'; y='y';
var
p:array['x'..'y',1..2000] of integer;
i,j,l,x0,y0,len,ranx,rany,num,sk,speed:integer;
esc,quit,pause:boolean;
dir,newdir:byte;
{=====================}
function mkstr(a:longint):string;
var s: string;
begin
str(a,s);
mkstr := s;
end;
{---------------------}
procedure newran;
var r1,r2,r3,r4:integer;
begin
repeat
ranx:=random(getmaxy) div 5 *5;
rany:=random(getmaxy) div 5 *5;
r1:=getpixel(ranx+5,rany);
r2:=getpixel(ranx-5,rany);
r3:=getpixel(ranx,rany+5);
r4:=getpixel(ranx,rany-5);
until ((ranx>7)and(ranx<getmaxy-7)and(rany>7)and(rany<getmaxy-7))and
((r1<>10)and(r2<>10)and(r3<>10)and(r4<>10));
end;
{---------------------}
procedure playing;
BEGIN
cleardevice;
esc:=false;
dir:=1;
x0:=getmaxx div 2-200;
y0:=getmaxy div 2;
len:=20;
num:=0;sk:=0;

setcolor(14);
settextstyle(defaultfont,horizdir,2);
outtextxy(getmaxx div 2 -250,getmaxy div 2 ,'SELECT THE SPEED: (0..9)...');
repeat
speed:=ord(readkey)-48;
until (speed<=9)and(speed>=0);
outtextxy(getmaxx div 2 +185,getmaxy div 2,mkstr(speed));
delay(30000);
cleardevice;
setcolor(15);
settextstyle(defaultfont,horizdir,1);
outtextxy(getmaxx-100,30,'SPEED   ');
outtextxy(getmaxx-50,30,mkstr(speed));
outtextxy(getmaxx-100,15,'SKORE     ');
outtextxy(getmaxx-50,15,mkstr(0));
setcolor(12);
outtextxy(getmaxx-150,250,'Press <Esc>');
outtextxy(getmaxx-150,265,'for exit');
outtextxy(getmaxx-150,300,'Press <Space>');
outtextxy(getmaxx-150,315,'for pause');

setcolor(14);
line(0,0,getmaxy,0);
line(0,0,0,getmaxy);
line(getmaxy,0,getmaxy,getmaxy);
line(0,getmaxy,getmaxy,getmaxy);

newran;
setfillstyle(solidfill,9);
bar(ranx-5,rany-5,ranx+5,rany+5);

for i:=0 to 2000 do begin
p[x,i]:=getmaxx;
p[y,i]:=getmaxy;
end;

repeat
if keypressed then begin
 case readkey of
  #77: newdir:=1;
  #80: newdir:=2;
  #75: newdir:=3;
  #72: newdir:=4;
  #27:esc:=true;
  #32:pause:=true;
 end;
 if pause=true then begin
  pause:=false; repeat until keypressed;
 end;
 memw[0:$41a]:=memw[0:$41c];
end;
if (newdir=1)and(dir<>3)then dir:=newdir;
if (newdir=2)and(dir<>4)then dir:=newdir;
if (newdir=3)and(dir<>1)then dir:=newdir;
if (newdir=4)and(dir<>2)then dir:=newdir;
case dir of
 1: x0:=x0+5;
 2: y0:=y0+5;
 3: x0:=x0-5;
 4: y0:=y0-5;
end;
p[x,1]:=x0;
p[y,1]:=y0;
for i:=len downto 2 do begin
 p[x,i]:=p[x,i-1];
 p[y,i]:=p[y,i-1];
end;
if (x0<=5)or(x0>=getmaxy-5)or(y0<=5)or(y0>=getmaxy-5) then esc:=true;

if (dir=1)and(getpixel(x0+5,y0)=10)then esc:=true;
if (dir=2)and(getpixel(x0,y0+5)=10)then esc:=true;
if (dir=3)and(getpixel(x0-5,y0)=10)then esc:=true;
if (dir=4)and(getpixel(x0,y0-5)=10)then esc:=true;

if (((x0+10>=ranx)and(ranx>=x0-10))and((y0+10>=rany)and(rany>=y0-10)))then begin
 num:=num+1;
 setcolor(0);
 settextstyle(defaultfont,horizdir,1);
 outtextxy(getmaxx-51,15,'ЫЫЫЫЫ');
 setcolor(15);
 outtextxy(getmaxx-50,15,mkstr(num));
 len:=len+5;
 setfillstyle(solidfill,0);
 bar(ranx-5,rany-5,ranx+5,rany+5);
 newran;
 setfillstyle(solidfill,9);
 bar(ranx-5,rany-5,ranx+5,rany+5);
end;
setfillstyle(solidfill,10);
bar(x0-4,y0-4,x0+4,y0+4);
setfillstyle(solidfill,0);
bar(p[x,len]-4,p[y,len]-4,p[x,len]+4,p[y,len]+4);

delay(3000-2500*speed div 9);
until esc;
END;
{=====================}
begin
initgraph(i,i,'');
randomize;
esc:=false;
playing;
repeat
 setcolor(12);
 settextstyle(defaultfont,horizdir,4);
 outtextxy(getmaxx div 2 -250,getmaxy div 2,'GAME OVER');
 setcolor(15);
 settextstyle(defaultfont,horizdir,2);
 outtextxy(getmaxx div 2 -250,getmaxy div 2 +100,'Play again? (y/n)...');
 case readkey of
  'y': playing;
  'n': quit:=true;
 end;
until quit;
closegraph;
end.
 К началу страницы 
+ Ответить 
 
 Ответить  Открыть новую тему 
Ответов
сообщение
Сообщение #2


Бывалый
***

Группа: Пользователи
Сообщений: 209

Репутация: -  0  +


ну и наконец последняя IV часть:
BEGIN
  FillChar(SnakeX,SizeOf(SnakeX),0);
  FillChar(SnakeY,SizeOf(SnakeY),0);
  FillChar(Screen,SizeOf(Screen),' ');

  Assign(FileChamp,FileName);
  {$I-}
  Reset(FileChamp);
  {$I+}
  if IOresult<>0 then
  begin
     Rewrite(FileChamp);
     Close(FileChamp);
     ClearResults;
  end else Close(FileChamp);

  OrigMode:=LastMode;
  TextMode(CO80 or Font8x8);
  HideCursor;
  Randomize;

  REPEAT
     TextColor(ColorBord);
     DrawWindow(1,1,80,49);
     TitleText;
     TextBackGround(Blue);
     DrawWindow(26,20,54,40);
     TextColor(White);
     Gotoxy(31,20);Write(' Choose Game Level ');
     TextColor(LightGreen);
     TextBackGround(Black);
     Gotoxy(3,48);  Write('Version 1.0 beta');
     Gotoxy(62,48); Write('© IvsSoft Corp.');

     j:=24;
     CurChoice:=1;
     for i:=1 to High(Menu) do
     begin
      Gotoxy(34,j);
      Write(Menu[i]);
      if j=30 then j:=34 else Inc(j,2);
     end;
     j:=24;
     TextColor(Black); TextBackGround(Green);
     Gotoxy(34,j);
     Write(Menu[CurChoice]);
     Repeat
      if KeyPressed then
      begin
         Ch:=ReadKey;
         if Ch=#0 then
         begin
            Case ReadKey of

            { Up } #72 : if CurChoice>0 then
                     begin
                        Gotoxy(34,j);
                        TextColor(LightGreen);
                        TextBackGround(Black);
                        Write(Menu[CurChoice]);
                        if j=34 then j:=30 else Dec(j,2);
                        Dec(CurChoice);
                        if CurChoice=0 then
                        begin
                         CurChoice:=High(Menu);
                         j:=36;
                        end;
                        Gotoxy(34,j);
                        TextColor(Black);
                        TextBackGround(Green);
                        Write(Menu[CurChoice]);
                     end;
            {Down} #80 : if CurChoice <= High(Menu) then
                     begin
                        Gotoxy(34,j);
                        TextColor(LightGreen);
                        TextBackGround(Black);
                        Write(Menu[CurChoice]);
                        if j=30 then j:=34 else Inc(j,2);
                        Inc(CurChoice);
                        if CurChoice>High(Menu) then
                        begin
                         CurChoice:=1;
                         j:=24;
                        end;
                        Gotoxy(34,j);
                        TextColor(Black);
                        TextBackGround(Green);
                        Write(Menu[CurChoice]);
                     end;
            end;
         end;
      end;
     Until  Ch=#13;

     TextBackGround(Black);
     TextColor(ColorSnaKe);
     Repeat
      CountBombs:=0;
      Case CurChoice of
         1 : begin CountBombs:= 0; LevSpeed:=1; end;
         2 : begin CountBombs:= 3; LevSpeed:=3; end;
         3 : begin CountBombs:= 7; LevSpeed:=4; end;
         4 : begin CountBombs:=10; LevSpeed:=5; end;
         5 : begin BestResults;ch:=#0; break end;
         6 : Break;
      end;
      Num:=CurChoice;

      ClearField;
      iExit    := FALSE; Speed:=1;
      Direction:= Left;  Score:= 0;
      Sections := 4;     Pause:=60;
      CreateBombs;
      for i:=1 to 5 do PutBonus;
      Border;
      Info;
      TextColor(White);
      Gotoxy(34,25); Write('Press Any Key...');
      repeat until KeyPressed;
      Gotoxy(34,25); Write('                ');
      TextColor(ColorSnaKe);
      InitSnake(40,25);

      Repeat
         if KeyPressed then
         begin
            Ch:=Readkey;
            if Ch=#0 then
            begin
             Case Readkey of

             { UP } #72  : if Direction <> Down  then Direction:= Up;
             {Down} #80  : if Direction <> Up    then Direction:= Down;
             { <- } #75  : if Direction <> Right then Direction:= Left;
             { -> } #77  : if Direction <> Left  then Direction:= Right;

             end
            end else if Ch=#112 then repeat until keypressed;

         end;

         Delay(Pause);
         MoveSnake;

      Until (Ch=#27) OR iExit;
      TextBackGround(Blue);
      TextColor(ColorBord);
      DrawWindow(30,22,50,28);
      TextColor(White);
      Gotoxy(36,24);Write('Game Over');
      TextColor(ColorBord);
      Gotoxy(32,26);Write('Play again (y/n) ?');
      TextBackGround(Black);

      repeat
         Ch:=UpCase(readkey);
      until (Ch='Y') or (Ch='N');

     Until Ch='N';

  UNTIL CurChoice = 6;

  TextMode(OrigMode);
  ShowCursor;

END.


--------------------
Если вы хотите чаще встречаться с понравившейся девушкой установите ей Windows'95
 Оффлайн  Профиль  PM 
 К началу страницы 
+ Ответить 

Сообщений в этой теме
Clane   Игра "Змейка" !   26.03.2003 15:47
Ivs   Re: Игра "Змейка" !   26.03.2003 16:08
Ivs   Re: Игра "Змейка" !   26.03.2003 16:10
Ivs   Re: Игра "Змейка" !   26.03.2003 16:14
Ivs   Re: Игра "Змейка" !   26.03.2003 16:17
Ivs   Re: Игра "Змейка" !   26.03.2003 16:24
AlaRic   Re: Игра "Змейка" !   26.03.2003 20:42
Ivs   Re: Игра "Змейка" !   26.03.2003 21:05
wormball   Re: Игра "Змейка" !   8.04.2003 19:49
AlaRic   Re: Игра "Змейка" !   8.04.2003 22:13
GLuk   Re: Игра "Змейка" !   8.04.2003 22:19
wormball   Re: Игра "Змейка" !   12.04.2003 19:51


 Ответить  Открыть новую тему 
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 





- Текстовая версия 29.04.2024 2:30
500Gb HDD, 6Gb RAM, 2 Cores, 7 EUR в месяц — такие хостинги правда бывают
Связь с администрацией: bu_gen в домене octagram.name