Арканоид на Паскале

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+1<a[i+1])and(y-radius+1>a[i+1]-20))

or(y+radius-1=a[i+1]-20)or((y+radius-1<a[i+1])and(y+radius-1>a[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-1<a[i+1])and(y+radius-1>a[i+1]-20))

or(y-radius+1=a[i+1])or((y-radius+1<a[i+1])and(y-radius+1>a[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<65535 then inc(pause);

#42{'*'}:if pause >2 then dec(pause);


Страница: