При повороте змейки видно меню

Общие вопросы: версии и диалекты, синтаксис языка, cтруктуры и типы данных (массивы, строки, списки...), обработка данных и т.д.
Ответить
Sega
Сообщения: 2
Зарегистрирован: 09 май 2015, 12:11

09 май 2015, 22:33

Попытался написать меню к змейки, теперь при повороте змейки видно меню. Помогите пожалуйста как-нибудь доработать. Просто сам в программирование "ни бум бум", поэтому буду надеяться, что вы уделите мне своё время. Заранее огромное спасибо.
Uses crt, graphABC, events,timers;
type
TDirection = (None, Left, Right, Up, Down);
const
r=15 ;
B=20;
d=8;

Var
i, a: integer;
s: string[63];
k: char;
x,t,y,z,xr,yr,prin1,prin2,prin3,prin4,prin5,g,s4et,prin6: integer;
Direction :TDirection;
xs,ys,bufx,bufy:array[1..200]of integer;

Procedure BuildMenu;

Const
l: array[1..5] of string[5] = (
'Easy','Medium','Hard', 'About', 'Exit');
Begin
ClrScr;
//cursoroff;
For i := 1 to 5 do
begin
If i = a then
TextColor(Red)
Else TextColor(Black);
gotoxy(44,10+i);
WriteLn(l);
end;
End;

procedure shar3;
begin
SetBrushColor(clYellow);
circle(xs[g],ys[g],r);
end;

procedure Circl;
begin
SetBrushColor(clred);
circle(x,y,B);
end;

procedure rshar ;
begin
xr:=Random(WindowWidth) ;
yr:=Random( WindowHeight);
end;

procedure rshar2;
begin
SetBrushColor(clgreen);
circle(xr,yr,r);
end;

procedure XP(Key:integer);
begin
case Key of
VK_Left: Direction := Left ;
VK_Right :D irection := Right ;
VK_UP: Direction := UP ;
VK_Down: Direction :=Down ;
end;
circle(x,y,r);
end;

procedure pause;
begin
SetWindowSize(640,480);
for i:=1 to 1 do
begin
Circl;
rshar2;
ClearWindow;
rshar2 ;
prin1:=(xr-x+r)*(xr-x+r)+(yr-y)*(yr-y) ;
prin2:=(xr-x-r)*(xr-x-r)+(yr-y)*(yr-y) ;
prin3:=(xr-x)*(xr-x)+(yr-y+r)*(yr-y+r) ;
prin4:=(xr-x)*(xr-x)+(yr-y-r)*(yr-y-r) ;
prin5:=R*R;
if (prin1)<=(prin5) then begin
rshar ;
s4et:=s4et+1;
end;

if (prin2)<=(prin5) then begin
rshar ;
s4et:=s4et+1;
end;
if (prin3)<=(prin5) then begin
rshar ;
s4et:=s4et+1;
end;
if (prin4)<=(prin5) then begin
rshar ;
s4et:=s4et+1;
end;

case Direction of
Left: begin x:=x-d; if x<=0 then x:=WindowWidth end;
Up: begin y:=y-d; if y<=0 then y:=WindowHeight end;
Right: begin x:=x+d; if x>=WindowWidth then x:=0 end;
Down: begin y:=y+d; if y>=WindowHeight then y:=0 end;
end;
xs[1]:=x;
ys[1]:=y;
for g:=1 to s4et do
begin
bufx[g]:=xs[g];
bufy[g]:=ys[g];

end;
for g:=1 to s4et do
begin
xs[g+1]:=bufx[g];
ys[g+1]:=bufy[g] ;
end;
for g:=2 to s4et do
shar3;
Circl;
end;
end;
Procedure Easy;
begin
rshar;
s4et:=2;

Direction := None;

x:=WindowWidth div 2;
y:=WindowHeight div 2;
OnKeyDown:=XP;
t:=CreateTimer(70, pause);
end;
Procedure Medium;
begin
rshar;
s4et:=2;

Direction := None;

x:=WindowWidth div 2;
y:=WindowHeight div 2;
OnKeyDown:=XP;
t:=CreateTimer(50, pause);
end;
Procedure Hard;
begin
rshar;
s4et:=2;

Direction := None;

x:=WindowWidth div 2;
y:=WindowHeight div 2;
OnKeyDown:=XP;
t:=CreateTimer(25, pause);
end;
Procedure About;
Begin
clrscr;
Textcolor(Red);
Gotoxy(18,4);
Write(' ÓðГ*ëüñêèé ôåäåðГ*ëüГ*ûé ГіГ*èâåðñèòåò ГЁГ¬. ГЃ.ГЌ. ÅëüöèГ*Г*');
Gotoxy(20,5);
Write('ГЉГ*ôåäðГ* ÂîäîñГ*Г*áæåГ*ГЁГї ГЁ ÂîäîîòâåäåГ*ГЁГї');
Gotoxy(12,16);
Write('ÊóðñîâГ*Гї Г°Г*áîòГ*');
Gotoxy(12,17);
Write('ГЏГ® ГЁГ*ôîðìГ*ГІГЁГЄГҐ');
Gotoxy(12,18);
Write('15-ГЈГ°Г*Г*Г*ГЁГЄ');
Gotoxy(12,19);
Write('ÃðóïïГ*: CГ’-140013');
Gotoxy(12,20);
Write('ÑòóäåГ*ГІ: ГѓГіГЎГ* ГЌГ*ГІГ*ëèÿ "ГЉГ*ГЄГ*Гї-ГІГ®"-ГўГ*Г* (äîïèøè ñâî¸ îò÷åñòâî)');
Gotoxy(30,25);
Write('ГЈ.Г…ГЄГ*òåðèГ*áóðã 2015 ГЈ.');
Readln;
writeln('Press <SPACE> to quit.');
while true do
begin
k:=readkey;
if k=#32 then
exit;
end;
End;
{------------------------------------------------}

Begin
SetWindowWidth(768);
SetWindowHeight(576);

a := 1;
BuildMenu;

Repeat
k := ReadKey;
If k = #0 then begin
k := ReadKey;
Case k of
#72: begin
a := a - 1;
If a < 1 then a := 5;
end;
#80: begin
a := a + 1;
If a > 5 then a := 1;
end;
end;
end
Else
begin
If k = #13 then
Case a of
1: Easy;
2: Medium;
3: Hard;
4: About;
5: Exit;
end;
end;
BuildMenu;

Until k = #27;
End.
Ответить