interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Gauges;
type
ttanki=record
live,x,y,nom,s,sp,time,bn:integer;
bon:boolean;
end;
tpulya=record
ya,x,y,nom:integer;
visible:boolean;
end;
TForm1 = class(TForm)
Timer1: TTimer;
Gauge1: TGauge;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private procedure novur;
{ Private declarations }
public
{ Public declarations }
end;
var
path:string;
Form1: TForm1;
img:array[1..3]of tbitmap;
img2:array [1..3,1..3] of TBitmap;
bah:array [1..4] of tbitmap;
map:array[0..8,0..23]of integer;
pulya:array[1..2]of tbitmap;
vb:array[1..3]of tbitmap;
x1,m,b,d1,p,d2,n,kol,nt,y1,s,time2,l,g:integer;
pula:array[1..301]of tpulya;
tanks:array[1..20]of ttanki;
buf,med:tbitmap;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
path:=Extractfiledir(Application.ExeName);
for i:=1 to 3 do
begin
img[i]:=TBitmap.Create;
img[i].TransparentColor:=clwhite;
img[i].Transparent:=true;
img[i].LoadFromFile(path+'\img2\i'+inttostr(i)+'.bmp');;
end;form1.Top:=0;
form1.BorderStyle:=bsdialog;
form1.Width:=576;
form1.Height:=724;
for i:=1 to 3 do
begin
vb[i]:=tbitmap.Create;
vb[i].LoadFromFile(path+'\img2\v'+inttostr(i)+'.bmp');;
end;
begin
for i:=1 to 3 do
begin
img2[1,i]:=TBitmap.Create;
img2[1,i].TransparentColor:=clwhite;
img2[1,i].Transparent:=true;
img2[1,i].LoadFromFile(path+'\img2\n'+inttostr(i)+'.bmp');
img2[2,i]:=TBitmap.Create;
img2[2,i].TransparentColor:=clwhite;
img2[2,i].Transparent:=true;
img2[2,i].LoadFromFile(path+'\img2\s'+inttostr(i)+'.bmp');
img2[3,i]:=TBitmap.Create;
img2[3,i].LoadFromFile(path+'\img2\k'+inttostr(i)+'.bmp');
end;
end;
for i:=1 to 4 do
begin
bah[i]:=TBitmap.Create;
bah[i].Transparent:=true;
bah[i].LoadFromFile(path+'\img2\bah'+inttostr(i)+'.bmp');
end;
for i:=1 to 2 do
begin
pulya[i]:=TBitmap.Create;
pulya[i].TransparentColor:=clwhite;
pulya[i].Transparent:=true;
pulya[i].LoadFromFile(path+'\img2\p'+inttostr(i)+'.bmp');
end;
gauge1.Height:=32;gauge1.Width:=100;gauge1.Top:=32;gauge1.Left:=0;gauge1.foreColor:=clred;
for i:=1 to 301 do
begin
pula[i].x:=0;
pula[i].y:=0;
pula[i].nom:=0;
pula[i].visible:=false;
pula[i].ya:=0;
end;
begin
buf:=tbitmap.Create;
buf.Width:=576;buf.Height:=724+96;
end;
begin
med:=TBitmap.Create;
med.TransparentColor:=clblack;
med.Transparent:=true;
med.LoadFromFile(path+'\img2\apt.bmp');
end;
l:=0;
novur;
end;
procedure tform1.novur;
var i,j:integer;
begin
y1:=64*10+96;s:=1;g:=0;time2:=0;d1:=-628;d2:=-692;kol:=0;nt:=0;
m:=0;p:=1;
for i:=1 to 20 do
begin
tanks[i].nom:=1;
tanks[i].time:=0;
tanks[i].s:=1;
tanks[i].live:=0;
tanks[i].x:=-1;
tanks[i].y:=-1;
tanks[i].sp:=2;
tanks[i].bn:=6;
tanks[i].bon:=true;
end;
timer1.Enabled:=true;
gauge1.Progress:=100;
for i:=0 to 8 do
for j:=0 to 23 do
map[i,j]:=3;
randomize;
n:=0;
while n<=7 do
begin
i:=random(9);
j:=random(24);
b:=(random(2))+1;
map[i,j]:=b;
inc(n);
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var i,j:integer;u:boolean;
begin
for i:=1 to 20 do begin
if(tanks[i].live>0) then buf.Canvas.Draw(tanks[i].x,tanks[i].y,img2[tanks[i].nom,tanks[i].s]);
tanks[i].y:=tanks[i].y+tanks[i].sp;inc(tanks[i].s);if tanks[i].s>3 then tanks[i].s:=1;
inc(tanks[i].time);inc(tanks[i].bn);
if(tanks[i].live<=0)and(tanks[i].bn<5)then begin
if tanks[i].nom=1 then buf.Canvas.Draw(tanks[i].x,tanks[i].y,bah[tanks[i].bn]);
if tanks[i].nom=2 then buf.Canvas.Draw(tanks[i].x+24,tanks[i].y+24,bah[tanks[i].bn]);
if tanks[i].nom=3 then buf.Canvas.Draw(tanks[i].x-12,tanks[i].y+24,bah[tanks[i].bn]);
end;
if(tanks[10].live<=0)and(tanks[10].bn>=5)and(tanks[kol].bon=true)then begin
if tanks[10].nom=1 then buf.Canvas.Draw(tanks[10].x,tanks[10].y,med);
if tanks[10].nom=2 then buf.Canvas.Draw(tanks[10].x+24,tanks[10].y+24,med);
if tanks[10].nom=3 then buf.Canvas.Draw(tanks[10].x-12,tanks[10].y+24,med);
if((tanks[10].nom=1)and((x1+32)div 64=(tanks[10].x+32)div 64)and
((y1+32)div 64=(tanks[10].y+32)div 64))or((tanks[10].nom=2)and((x1+56)div 64=(tanks[10].x+56)div 64)and
((y1+32)div 64=(tanks[10].y+56)div 64))or((tanks[10].nom=3)and((x1+20)div 64=(tanks[10].x+20)div 64)and
((y1+32)div 64=(tanks[10].y+56)div 64))then begin gauge1.Progress:=gauge1.Progress+10;tanks[kol].bon:=false;end;
end; if(tanks[20].live<=0)and(tanks[20].bn>=5)and(tanks[kol].bon=true)then begin
if tanks[20].nom=1 then buf.Canvas.Draw(tanks[20].x,tanks[20].y,med);
if tanks[20].nom=2 then buf.Canvas.Draw(tanks[20].x+24,tanks[20].y+24,med);
if tanks[20].nom=3 then buf.Canvas.Draw(tanks[20].x-12,tanks[20].y+24,med);
if((tanks[20].nom=1)and((x1+32)div 64=(tanks[20].x+32)div 64)and
((y1+32)div 64=(tanks[20].y+32)div 64))or((tanks[20].nom=2)and((x1+56)div 64=(tanks[20].x+56)div 64)and
((y1+32)div 64=(tanks[20].y+56)div 64))or((tanks[20].nom=3)and((x1+20)div 64=(tanks[20].x+20)div 64)and
((y1+32)div 64=(tanks[20].y+56)div 64))then begin gauge1.Progress:=gauge1.Progress+10;tanks[kol].bon:=false;end;
end;
END;buf.Canvas.TextOut(0,96,'Целей уничтожено:'+inttostr(m)+' Выстрелов сделано:'+inttostr(g));
buf.Canvas.Font.Color:=clred;buf.Canvas.Font.Height:=20;
for i:=1 to 301 do begin
if pula[i].visible=true then buf.Canvas.Draw(pula[i].x,pula[i].y,pulya[pula[i].nom]);
end;
s:=s+1;if s>3 then s:=1;inc(time2);
buf.Canvas.Draw(x1,y1,img[s]);
form1.Canvas.Draw(0,-96,buf);
timer1.Interval:=10;
for i:=1 to 150 do begin
if pula[i].visible=true then
for j:=1 to 20 do begin
if (tanks[j].nom=1)and((tanks[j].live>0)and((pula[i].x+8)div 64=(tanks[j].x+32)div 64)
and((pula[i].y+8)div 64=(tanks[j].y+32)div 64)and(pula[i].ya=1))or
(tanks[j].nom=2)and((tanks[j].live>0)and((pula[i].x+8)div 96=(tanks[j].x+48)div 96)
and((pula[i].y+8)div 96=(tanks[j].y+48)div 96)and(pula[i].ya=1))or
(tanks[j].nom=3)and((tanks[j].live>0)and((pula[i].x+8)div 40=(tanks[j].x+20)div 40)
and((pula[i].y+8)div 96=(tanks[j].y+48)div 96)and(pula[i].ya=1))
then
begin
dec(tanks[j].live);
pula[i].visible:=false;if tanks[j].live<=0 then inc(m);
if(tanks[j].live<=0)and(tanks[j].bn>=0)then tanks[j].bn:=0;
end;
end;
if (pula[i].visible=true)and(pula[i].nom=1)then
pula[i].y:=pula[i].y-18;
if pula[i].y<=96 then pula[i].visible:=false;
end;
if kol=20 then kol:=0;
for i:=151 to 301 do begin
if pula[i].visible=true then begin
if(gauge1.Progress>0)and((pula[i].x+8)div 64=(x1+32)div 64)
and((pula[i].y+8)div 64=(y1+32)div 64)then begin gauge1.Progress:=gauge1.Progress-1;
pula[i].visible:=false;end;end;
if (pula[i].visible=true)and(pula[i].nom=2)then
pula[i].y:=pula[i].y+5;
if (pula[i].y<=96)or(pula[i].y>=820)then pula[i].visible:=false;
for j:=1 to 20 do
begin
if(tanks[j].live>0) then
begin
u:=false;
if (tanks[j].time>=100)and(u=false)and(pula[i].visible=false) then
begin
if tanks[j].nom=1 then begin pula[i].x:=tanks[j].x+32;pula[i].y:=tanks[j].y+80;end;
if tanks[j].nom=2 then begin pula[i].x:=tanks[j].x+48;pula[i].y:=tanks[j].y+112;end;
if tanks[j].nom=3 then begin pula[i].x:=tanks[j].x+20;pula[i].y:=tanks[j].y+112;end;
pula[i].visible:=true;pula[i].nom:=2;
u:=true; tanks[j].time:=0;
end;
end;end;
end;
if gauge1.Progress<=0 then begin timer1.Enabled:=false;showmessage
('Ваш рекорд:'+inttostr(l)+' Целей уничтожено:'+inttostr(m)+' Выстрелов сделано:'+inttostr(g));
novur;for i:=1 to 301 do pula[i].visible:=false;end;if m>l then l:=m;
inc(nt);
if (nt=50)and(kol<20)then
begin
nt:=0;inc(kol);
if ((kol=5)or(kol=1)or(kol=10)or
(kol=2)or(kol=4)or
(kol=7)or(kol=6)or(kol=9)or
(kol=8)or(kol=3)or
(kol=11)or(kol=12)or(kol=13)or
(kol=14)or(kol=15)or
(kol=16)or(kol=17)or(kol=18)or
(kol=19)or(kol=20))then
tanks[kol].x:=random(9)*64;
tanks[kol].y:=0;tanks[kol].nom:=random(3)+1;
if tanks[kol].nom=1 then begin
tanks[kol].live:=3;tanks[kol].sp:=3;end;
if tanks[kol].nom=2 then begin
tanks[kol].live:=5;tanks[kol].sp:=2;end;
if tanks[kol].nom=3 then begin
tanks[kol].live:=10;tanks[kol].sp:=1;end;
end;
if d1>=724 then d1:=-628;if d2>=32 then d2:=-628-692;
begin
for i:=0 to 8 do
for j:=0 to 11 do
buf.Canvas.Draw(i*64,j*64+d1,vb[map[i,j]]);
d1:=d1+1;d2:=d2+1;
for i:=0 to 8 do
for j:=12 to 23 do
buf.Canvas.Draw(i*64,j*64+d2,vb[map[i,j]]);
end;
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var r:trect;
begin
if (x>=32) and (x<=form1.Width-32) then
x1:=x-32; r:=boundsrect;clipcursor(@r);
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState); var i:integer; u:boolean;
begin
if key=VK_space then
begin
u:=false;
for i:=1 to 150 do begin
if (time2>=5)and(pula[i].visible=false)and(u=false)then begin
if pula[i].nom=1 then begin
pula[i].x:=x1+24;
pula[i].y:=y1-16;
end;
time2:=0;
pula[i].nom:=1;
pula[i].visible:=true;
pula[i].ya:=1;
u:=true;inc(g);
end;
end;
end;
end;
end.