Âõîäíûå äàííûå: íåò;
Âûõîäíûå äàííûå: íåò;
2. Procedure vostanovka_colors;
Íàçíà÷åíèå: âîññòàíàâëèâàåò öâåòà ñî ñòàíäàðòíûìè îòòåíêàìè;
Âõîäíûå äàííûå: íåò;
Âûõîäíûå äàííûå: íåò;
Òåêñò ïðîãðàììû:
program mark_ball;
uses graph,crt,mymouse,markel,mark_zas;
procedure initgr;
var grdriver,grmode:integer;
begin
grdriver:=vga;
grmode:=vgahi;
initgraph(grdriver,grmode,'');
if GraphResult <> grOk then halt;
end;
procedure vostanovka_colors;
begin
setrgbpalette(black,0,0,0);
setrgbpalette(blue,0,0,40);
setrgbpalette(green,0,40,0);
setrgbpalette(cyan,0,40,40);
setrgbpalette(red,40,7,7);
setrgbpalette(magenta,40,0,40);
setrgbpalette(brown,40,30,0);
setrgbpalette(lightgray,49,49,49);
setrgbpalette(darkgray,26,26,26);
setrgbpalette(lightblue,0,0,63);
setrgbpalette(lightgreen,9,63,9);
setrgbpalette(lightcyan,0,63,63);
setrgbpalette(lightred,63,10,10);
setrgbpalette(lightmagenta,44,0,63);
setrgbpalette(yellow,63,63,18);
setrgbpalette(white,63,63,63);
end;
var y_planka,xmax,
x1_dv,x2_dv,x,y,i:t_kubik;
x_get,y_get,x_get_pred:word;
dx,dy:t_dx_dy;
a:t_arr;
numbering,liv:byte;
kol_kub:kol_kubik;
lb,rb,tb,dviguna:boolean;
buttoncount,errorcode,koeff:byte;
pause:word;
score:integer;
s2:string;
begin
s2:='Click to start';
initgr;
zastavka(s2);
vostanovka_colors;
setlinestyle(0,0,1);
randomize;
cleardevice;
xmax:=getmaxx-radius-1;
y:=getmaxy-shir-radius-1;
y_planka:=getmaxy-shir-radius-1;
liv:=10;
score:=-10;
dviguna:=chem_play;
pausing(pause);
razmer_planki(koeff);
for numbering:=1 to 10 do
begin
perehod_level(numbering);
cleardevice;
planka_sharik(koeff);
level(a,numbering,kol_kub);
naverhu_number(numbering);
naverhu_liv(liv);
naverhu_kubiki(kol_kub,score);
dx:=-1;
dy:=-1;
{à ¬ª }
setcolor(random(14)+1);
rectangle(0,21,getmaxx,getmaxy);
if dviguna then dviguna_mouse(koeff,x,x1_dv,x2_dv,y)
else dviguna_keyboard(koeff,x,x1_dv,x2_dv,y);
while kol_kub>0 do
begin
zar_nar(x,y,dx,dy);
delay(pause);
if (y=radius+1+21) or
((x1_dv
begin dy:=-dy; musik; end else
if (x=xmax) or (x=radius+1) then
begin dx:=-dx; musik; end else
if y=y_planka then
begin
setcolor(0);
circle(x,y,radius);
setfillstyle(0,0);
bar3d(x1_dv,y1_dv,x2_dv,y2_dv,0,false);
dy:=-1;
death;
livs(liv,score);
case dviguna of
true:dviguna_mouse(koeff,x,x1_dv,x2_dv,y);
false:dviguna_keyboard(koeff,x,x1_dv,x2_dv,y);
end;
end;
case x of
1..49: begin i:=37;izchez_vv_niz(dy,x,y,i,a,kol_kub,score); end;
50..99: begin i:=75;izchez_vv_niz(dy,x,y,i,a,kol_kub,score); end;
100..148:begin i:=113;izchez_vv_niz(dy,x,y,i,a,kol_kub,score); end;
149..197:begin i:=151;izchez_vv_niz(dy,x,y,i,a,kol_kub,score); end;
198..246:begin i:=189;izchez_vv_niz(dy,x,y,i,a,kol_kub,score); end;
247..295:begin i:=227;izchez_vv_niz(dy,x,y,i,a,kol_kub,score); end;
296..344:begin i:=265;izchez_vv_niz(dy,x,y,i,a,kol_kub,score); end;
345..393:begin i:=303;izchez_vv_niz(dy,x,y,i,a,kol_kub,score); end;
394..442:begin i:=341;izchez_vv_niz(dy,x,y,i,a,kol_kub,score); end;
443..491:begin i:=379;izchez_vv_niz(dy,x,y,i,a,kol_kub,score); end;
492..540:begin i:=417;izchez_vv_niz(dy,x,y,i,a,kol_kub,score); end;
541..588:begin i:=455;izchez_vv_niz(dy,x,y,i,a,kol_kub,score); end;
589..637:begin i:=493;izchez_vv_niz(dy,x,y,i,a,kol_kub,score); end;
end;
bok_bok(dx,x,y,a,kol_kub,score);
ugolki(dx,dy,x,y,a,kol_kub,score);
case dviguna of
false:
if keypressed then
case readkey of
#75: left(koeff,x1_dv,x2_dv);
#77: right(koeff,x1_dv,x2_dv);
#27:begin closegraph; halt; end;
end;
true:
begin
getmousexy(x_get,y_get,lb,rb,tb);
if x_get_pred<>x_get then begin
setcolor(0);
setfillstyle(0,0);
bar3d(x1_dv,y1_dv,x2_dv,y2_dv,0,false);
setfillstyle(6,13);
setcolor(13);
x1_dv:=x_get;
x2_dv:=x1_dv+koeff*shir;
bar3d(x1_dv,y1_dv,x2_dv,y2_dv,0,false);
x_get_pred:=x_get; end;
if rb then begin closegraph;halt;end;
end;
end;
end;
dec(score,10);
end;
inc(score,10);
ochki(score);
s2:='The end of game';
zastavka(s2);
closegraph;
end.
Òåêñò ñêîíñòðóèðóåìûõ ìîäóëåé:
unit markel;
interface
uses crt,graph,mymouse,mark_zas;
var sverhu:string;
liv,numbering:byte;
const radius=7;
shir=15;
y1_dv=479-1;
y2_dv=479-shir;
type t_kubik=-10..640;
t_dx_dy=-1..1;
t_arr=array[1..494] of t_kubik;
kol_kubik=0..247;
procedure livs(var liv:byte;score:integer);
procedure perehod_level(const numbering:byte);
procedure planka_sharik(koeff:byte);
procedure musik;
procedure izchez_vv_niz(var dy:t_dx_dy;x,y,i:t_kubik;var a:t_arr;var kol_kub:kol_kubik;var score:integer);
procedure bok_bok(var dx:t_dx_dy;x,y:t_kubik;var a:t_arr;var kol_kub:kol_kubik;var score:integer);
procedure death;
procedure ugolki(var dx,dy:t_dx_dy;x,y:t_kubik;var a:t_arr;var kol_kub:kol_kubik;var score:integer);
procedure pausing(var pause:word);
procedure zapis(const xs,ys:t_kubik;i:t_kubik;var a:t_arr);
procedure level(var a:t_arr;const numbering:byte;var kol_kub:kol_kubik);
procedure left(const koeff:byte;var x1_dv,x2_dv:t_kubik);
procedure right(const koeff:byte;var x1_dv,x2_dv:t_kubik);
procedure dviguna_keyboard(const koeff:byte;var x,x1_dv,x2_dv:t_kubik;var y:t_kubik);
procedure dviguna_mouse(const koeff:byte;var x,x1_dv,x2_dv:t_kubik;var y:t_kubik);
procedure zar_nar(var x,y:t_kubik;const dx,dy:t_dx_dy);
function chem_play:boolean;
procedure razmer_planki(var koeff:byte);
procedure naverhu_liv(liv:byte);
procedure naverhu_number(numbering:byte);
procedure naverhu_kubiki(kol_kub:byte;var score:integer);
procedure naverhu_score(score:integer);
implementation
function chem_play:boolean;
var mask:boolean;
greenvalue,bluevalue:0..64;
i,j:-1..1;
begin
setcolor(blue);
settextstyle(4{GothicFont},horizdir,5);
settextjustify(1,1);
outtextxy(round(getmaxx / 3.3), round(getmaxy / 2.3),'Mouse');
setcolor(green);
outtextxy(round(getmaxx / 1.5), round(getmaxy / 2.3),'Keyboard');
i:=1;
j:=1;
greenvalue:=0;
bluevalue:=0;
while true do
begin
repeat
case mask of
true:begin
setRGBpalette(blue,0,0,bluevalue);
inc(bluevalue,i);
if (bluevalue = 63) or (bluevalue = 0) then
i:=-i;
end;
false:begin
setRGBpalette(green,0,greenvalue,0);
inc(greenvalue,j);
if (greenvalue = 63) or (greenvalue = 0) then
j:=-j;
end;
end;
until keypressed;
case readkey of
#75: mask:=true;
#77: mask:=false;
#13: begin chem_play:=mask; delay(5000); cleardevice; exit; end;
#27: begin closegraph; halt; end;
end;
end;
end;
procedure ugolki(var dx,dy:t_dx_dy;x,y:t_kubik;var a:t_arr;var kol_kub:kol_kubik;var score:integer);
procedure izchez(var dx,dy:t_dx_dy;var a:t_arr;var kol_kub:kol_kubik;i:word);
begin
setcolor(0);
setfillstyle(1,0);
bar3d(a[i],a[i+1],a[i]+48,a[i+1]-20,0,false);
musik;
a[i]:=0;
a[i+1]:=0;
dx:=-dx;
dy:=-dy;
dec(kol_kub);
musik;
naverhu_kubiki(kol_kub,score);
exit;
end;
var i:1..496;
begin
i:=1;
while i<=493 do
begin
if x-radius+1=a[i]+48 then
if (y-radius+1=a[i+1])or((y-radius+1a[i+1]-20))
or(y+radius-1=a[i+1]-20)or((y+radius-1a[i+1]-20))
then izchez(dx,dy,a,kol_kub,i);
if x+radius-1=a[i] then
if (y+radius-1=a[i+1]-20)or((y+radius-1a[i+1]-20))
or(y-radius+1=a[i+1])or((y-radius+1a[i+1]-20))
then izchez(dx,dy,a,kol_kub,i);
if y-radius+1=a[i+1] then
if (x-radius+1=a[i]+48)or((x-radius+1>a[i])and(x-radius+1<a[i]+48))
or(x+radius-1=a[i])or((x+radius-1>a[i])and(x+radius-1<a[i]+48))
then izchez(dx,dy,a,kol_kub,i);
if y+radius-1=a[i+1]-20 then
if (x+radius-1=a[i])or((x+radius-1>a[i])and(x+radius-1<a[i]+48))
or(x-radius+1=a[i]+48)or((x-radius+1>a[i])and(x-radius+1<a[i]+48))
then izchez(dx,dy,a,kol_kub,i);
inc(i,2);
end;
end;
procedure pausing(var pause:word);
var xmax,y_planka,x,y:t_kubik;
dx,dy:-1..1;
s:string;
redvalue,bluevalue:0..63;
i:-1..1;
begin
setcolor(lightgray);
s:='Adjust speed of a ball';{'îòðåãóëèðóéòå ñêîðîñòü øàðèêà'}
settextstyle(4{GothicFont},horizdir,5);
settextjustify(1,1);
outtextxy(getmaxx div 2, getmaxy div 2,s);
i:=1;
redvalue:=0;
bluevalue:=0;
repeat
repeat
setRGBpalette(lightgray,redvalue,0,bluevalue);
inc(bluevalue,i);
inc(redvalue,i);
until keypressed or (bluevalue=63) or (bluevalue=0);
i:=-i;
until keypressed;
cleardevice;
{ðàìêà}
setcolor(random(14)+1);
rectangle(0,0,getmaxx,getmaxy);
xmax:=getmaxx-radius-1;
y_planka:=getmaxy-shir-radius-1;
{ïëàíêà íà âåñü íèç}
setcolor(13);
setfillstyle(6,13);
bar3d(1,getmaxy-1,getmaxx,getmaxy-shir,0,false);
{øàðèê íàä ïëàíêîé}
x:=getmaxx div 2;
y:=getmaxy-shir-radius-1;
setcolor(10);
circle(x,y,radius);
dx:=1;
dy:=-1;
pause:=6;
repeat
while not(keypressed) do
begin
zar_nar(x,y,dx,dy);
delay(pause);
if y=radius+1 then
begin dy:=-dy; musik; end else
if x=xmax then
begin dx:=-dx; musik; end else
if y=y_planka then
begin dy:=-dy; musik; end else
if x=radius+1 then
begin dx:=-dx; musik; end;
end;
case readkey of
#45{'-'}:if pause
#42{'*'}:if pause >2 then dec(pause);
#13:begin cleardevice; exit; end;
end;
until false;
end;
procedure razmer_planki(var koeff:byte);
var s:string;
x1,y1,x2,y2:integer;
i:-1..1;
redvalue,bluevalue:0..63;
begin
setcolor(red);
s:='Adjust the size of a rod'{'îòðåãóëèðóéòå ðàçìåð ïëàíêè'};
settextstyle(4{GothicFont},horizdir,5);
settextjustify(1,1);
outtextxy(getmaxx div 2, getmaxy div 2, s);
i:=1;
redvalue:=0;
bluevalue:=0;
repeat
repeat
setRGBpalette(red,redvalue,bluevalue,0);
inc(bluevalue,i);
inc(redvalue,i);
until keypressed or (redvalue=0) or (redvalue=63);
i:=-i;
until keypressed;
cleardevice;
{ðàìêà}
setcolor(random(14)+1);
rectangle(0,0,getmaxx,getmaxy);
{ïëàíêà ïîñåðåäèíå}
setcolor(13);
setfillstyle(6,13);
koeff:=4;
x1:=round(getmaxx/2-(koeff/2)*shir-1);
y1:=getmaxy-1;
x2:=round(getmaxx/2+(koeff/2)*shir);
y2:=getmaxy-shir;
bar3d(x1,y1,x2,y2,0,false);
repeat
if keypressed then
case readkey of
#42{'*'}:if koeff
begin
inc(koeff);
x1:=round(getmaxx/2-(koeff/2)*shir-1);
y1:=getmaxy-1;
x2:=round(getmaxx/2+(koeff/2)*shir);
y2:=getmaxy-shir;
bar3d(x1,y1,x2,y2,0,false);
end;
#45{-}:if koeff>2 then
begin
setcolor(0);
setfillstyle(0,0);
x1:=round(getmaxx/2-(koeff/2)*shir-1);
y1:=getmaxy-1;
x2:=round(getmaxx/2+(koeff/2)*shir);
y2:=getmaxy-shir;
bar3d(x1,y1,x2,y2,0,false);
dec(koeff);
setcolor(13);
setfillstyle(6,13);
x1:=round(getmaxx/2-(koeff/2)*shir-1);
y1:=getmaxy-1;
x2:=round(getmaxx/2+(koeff/2)*shir);
y2:=getmaxy-shir;
bar3d(x1,y1,x2,y2,0,false);
end;
#13:exit;
end;
until false;
end;
procedure livs(var liv:byte;score:integer);
var s2:string;
begin
dec(liv);
naverhu_liv(liv);
if liv=0 then
begin
ochki(score);
s2:='You have lost !';
zastavka(s2);
closegraph;
halt;
end;
end;
procedure perehod_level(const numbering:byte);
var i,j:30..330;
s:string;
begin
str(numbering,s);
s:='level '+s;
cleardevice;
setcolor(14);
settextstyle(4{GothicFont},horizdir,5);
settextjustify(1,1);
outtextxy(getmaxx div 2, getmaxy div 2, s);
i:=30;
j:=280;
{while (i<>330) and (j<>30) do
begin
sound(i);
delay(100);
sound(j);
delay(100);
inc(i);
dec(j);
end;
nosound;}
delay(5000);
end;
procedure planka_sharik(koeff:byte);
var x1,y1,x2,y2,x,y:integer;
begin
{ïëàíêà ïîñåðåäèíå}
setcolor(13);
setfillstyle(6,13);
x1:=round(getmaxx/2-(koeff/2)*shir-1);
y1:=getmaxy-1;
x2:=round(getmaxx/2+(koeff/2)*shir);
y2:=getmaxy-shir;
bar3d(x1,y1,x2,y2,0,false);
{øàðèê íàä ïëàíêîé}
x:=getmaxx div 2;
y:=getmaxy-shir-radius-1;
setcolor(10);
circle(x,y,radius);
end;
procedure musik;
begin
{sound(460);
delay(130);
nosound;}
end;
procedure izchez_vv_niz(var dy:t_dx_dy;x,y,i:t_kubik;var a:t_arr;var kol_kub:kol_kubik;var score:integer);
var p:-3..494;
begin
p:=i-36;
while (i>=p) and not((y-radius+1=a[i+1]) or (y+radius-1=a[i+1]-20)) do
dec(i,2);
if i
if (y-radius+1=a[i+1]) or (y+radius-1=a[i+1]-20) then
begin
setcolor(0);
setfillstyle(1,0);
bar3d(a[i],a[i+1],a[i]+48,a[i+1]-20,0,false);
musik;
a[i]:=0;
a[i+1]:=0;
dy:=-dy;
dec(kol_kub);
naverhu_kubiki(kol_kub,score);
end;
end;
procedure bok_bok(var dx:t_dx_dy;x,y:t_kubik;var a:t_arr;var kol_kub:kol_kubik;var score:integer);
var i:1..496;
begin
i:=1;
while i<=493 do
begin
if ((x+radius-1=a[i]) and (ya[i+1]-20)) or
((x-radius+1=a[i]+48) and (ya[i+1]-20)) then
begin
setcolor(0);
setfillstyle(1,0);
bar3d(a[i],a[i+1],a[i]+48,a[i+1]-20,0,false);
musik;
a[i]:=0;
a[i+1]:=0;
dx:=-dx;
dec(kol_kub);
musik;
naverhu_kubiki(kol_kub,score);
exit;
end;
inc(i,2);
end;
end;
procedure death;
var i:30..800;
begin
i:=800;
{while i<>30 do
begin
sound(i);
delay(10);
dec(i);
end;
nosound;}
end;
procedure zapis(const xs,ys:t_kubik;i:t_kubik;var a:t_arr);
begin
while a[i]<>0 do