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  +


II - часть
Procedure Border;
begin
  TextColor(ColorBomb);
  for i:=1 to 80 do
  begin
     Gotoxy(i, 1); Write(Bomb); Screen[ 1,i]:=Bomb;
     Gotoxy(i, 3); Write(Bomb); Screen[ 3,i]:=Bomb;
     Gotoxy(i,49); Write(Bomb); Screen[49,i]:=Bomb;
     Gotoxy(i,47); Write(Bomb); Screen[47,i]:=Bomb;
  end;
  for i:=1 to 49 do
  begin
     Gotoxy(1, i); Write(Bomb); Screen[i, 1]:=Bomb;
     Gotoxy(80,i); Write(Bomb); Screen[i,80]:=Bomb;
  end;
  TextColor(ColorSnaKe);
end;

Procedure DrawWindow(x1,y1,x2,y2:word);
const
  LU = #201; RU = #187;
  LD = #200; RD = #188;
  H  = #205; L  = #186;
begin
  Gotoxy(x1,y1); Write(LU); Gotoxy(x2,y1); Write(RU);
  Gotoxy(x1,y2); Write(LD); Gotoxy(x2,y2); Write(RD);
  for i:=x1+1 to x2-1 do
  begin
     Gotoxy(i,y1); Write(H);
     Gotoxy(i,y2); Write(H);
  end;
  for i:=y1+1 to y2-1 do
  begin
     Gotoxy(x1,i); Write(L);
     Gotoxy(x2,i); Write(L);
  end;
  Window(x1+1,y1+1,x2-1,y2-1); ClrScr; Window(1,1,80,50);
end;

Procedure Info;
begin
  TextColor(LightMagenta);
  Gotoxy(30, 2); Write('Speed : ',Speed:2);
  Gotoxy(45, 2); Write('Score : ',Score:2);
  TextColor(LightGreen);
  Gotoxy( 3,48); Write('Version 1.0 beta');
  Gotoxy(35,48); Write('The Snake !');
  Gotoxy(62,48); Write('© IvsSoft Corp.');
  TextColor(ColorSnaKe);
end;

Procedure ClearField;
begin
  Window(2,4,79,46); ClrScr; Window(1,1,80,50);
  for i:=4 to 46 do
     for j:=2 to 79 do
      Screen[i,j]:=' ';
end;

Procedure ViewScore;
begin
  TextColor(LightMagenta);
  Gotoxy(53,2); Write(Score:2);
  TextColor(ColorSnaKe);
end;

Procedure ViewSpeed;
begin
  TextColor(LightMagenta);
  Gotoxy(38,2); Write(Speed:2);
  TextColor(ColorSnaKe);
end;

Procedure PutSymbol(x,y : Word; Symbol : Char);
begin
  if (x in [1..ScreenX]) and (y in [1..ScreenY]) then
  begin
     Gotoxy(x,y);
     Write(Symbol);
     Screen[y,x]:=Symbol;
  end;
end;

Procedure PutBonus;
begin
  repeat
     ix:=Random(78)+2;
     iy:=Random(42)+4;
  until Screen[iY,iX]=' ';
  Bonus:=Chr(Random(4)+1);
  TextColor(Random(5)+10);
  PutSymbol(ix,iy,Bonus);
  TextColor(ColorSnake);
end;

Procedure CreateBombs;
begin
  TextColor(ColorBomb2);
  for i:=1 to CountBombs do
  begin
     repeat
      ix:=Random(78)+2;
      iy:=Random(42)+4;
     until (Screen[iy,ix]=' ') and not(ix in [30..50]) and (iy<>25);
     PutSymbol(ix,iy,Bomb2);
  end;
  TextColor(ColorSnaKe);
end;


Procedure InitSnake(x,y : Word);
begin
  for i:=1 to Sections do
  begin
     SnakeX[i]:=i+X;
     SnakeY[i]:=Y;
     Screen[Y,i+X]:=SnaKeSym;
  end;
  HatX:=SnakeX[1];
  HatY:=SnakeY[1];
end;

Procedure DeathSnaKe;
const Death : Array [1..6] of char = ('X','x','%',':','.',' ');
begin
  for i:=1 to 6 do
  begin
     for j:=2 to Sections do
     begin
      Gotoxy(SnakeX[j],SnakeY[j]); Write(Death[i]);
     end;
     Delay(100);
  end;
end;

Procedure BestResults;
begin
  Assign(FileChamp,FileName);
  Reset(FileChamp);
  TextBackGround(Blue);
  TextColor(ColorBord);
  DrawWindow(26,20,54,40);
  TextColor(White);
  Gotoxy(34,20); Write(' Best Results ');
  Gotoxy(30,23); Write('Level       Name  Score');
  TextColor(LightGreen);
  TextBackGround(Black);
  Gotoxy(28,26); Write(' Milksop.:');
  Seek(FileChamp,0); Read(FileChamp,Work); Write(Work.Name:8,Work.Res:7);
  Gotoxy(28,28); Write(' Plug Up!:');
  Seek(FileChamp,1); Read(FileChamp,Work); Write(Work.Name:8,Work.Res:7);
  Gotoxy(28,30); Write(' Die Hard:');
  Seek(FileChamp,2); Read(FileChamp,Work); Write(Work.Name:8,Work.Res:7);
  Gotoxy(28,32); Write(' Yo-ho-ho:');
  Seek(FileChamp,3); Read(FileChamp,Work); Write(Work.Name:8,Work.Res:7);
  Close(FileChamp);
  TextColor(White);
  TextBackGround(Blue);
  Gotoxy(31,37); Write('[ Press any key... ]');
  Readkey;
  TextBackGround(Black);
  TextColor(ColorBord);
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 5:48
500Gb HDD, 6Gb RAM, 2 Cores, 7 EUR в месяц — такие хостинги правда бывают
Связь с администрацией: bu_gen в домене octagram.name