interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, ExtCtrls, Gauges;

 

type

ttanki=record

pov,live,x,y,nom,s,sp,time,bn:integer;

end;

tpulya=record

ya,x,y,povorot:integer;

visible:boolean;

end;

  TForm1 = class(TForm)

    Timer1: TTimer;

    Gauge1: TGauge;

    Gauge2: TGauge;

    procedure FormCreate(Sender: TObject);

    procedure FormKeyDown(Sender: TObject; var Key: Word;

      Shift: TShiftState);

    procedure Timer1Timer(Sender: TObject);

  private

  procedure novur;

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

  path:string;

  img:array [1..4,1..2] of TBitmap;

  img2:array [1..2,1..4,1..2] of TBitmap;

  block:array [1..4] of tbitmap;

  bah:array [1..4] of tbitmap;

  bon:array [1..2] of tbitmap;

  x1,nb,zv,t,pos,y1,pov,b,x,g,m,time2,kol,nt,y,s,k:integer;

  puli:array [5..6] of TBitmap;

  pula:array[1..30]of tpulya;

  c:boolean;

  map,buf:tbitmap;

  grou:array [0..41,0..20]of integer;

  tanks:array[1..10]of ttanki;

  bonus:array [0..13,0..6]of integer;

implementation

 

{$R *.dfm}

 

procedure TForm1.FormCreate(Sender: TObject);

var i,j,l:integer;

begin

path:=Extractfiledir(Application.ExeName);

for i:=1 to 4 do

for j:=1 to 2 do

begin

img[i,j]:=TBitmap.Create;

img[i,j].TransparentColor:=clwhite;

img[i,j].Transparent:=true;

img[i,j].LoadFromFile(path+'\img\t'+inttostr(i)+inttostr(j)+'.bmp');;

end;

begin

for i:=1 to 4 do

for j:=1 to 2 do

begin

img2[1,i,j]:=TBitmap.Create;

img2[1,i,j].TransparentColor:=clwhite;

img2[1,i,j].Transparent:=true;

img2[1,i,j].LoadFromFile(path+'\img\v'+inttostr(i)+inttostr(j)+'.bmp');

img2[2,i,j]:=TBitmap.Create;

img2[2,i,j].TransparentColor:=clwhite;

img2[2,i,j].Transparent:=true;

img2[2,i,j].LoadFromFile(path+'\img\i'+inttostr(i)+inttostr(j)+'.bmp');

end;

end;

form1.Align:=alclient;form1.BorderStyle:=bsdialog;

gauge1.ForeColor:=clred;gauge1.Height:=36;gauge1.Width:=492;

gauge1.Top:=672;gauge1.Left:=864;

gauge2.ForeColor:=clnavy;gauge2.Height:=36;gauge2.Width:=492;

gauge2.Top:=672;gauge2.Left:=370;

 for j:=5 to 6 do

begin

puli[j]:=TBitmap.Create;

puli[j].Transparent:=true;

puli[j].LoadFromFile(path+'\img\d'+inttostr(j)+'.bmp');

end;

 for j:=1 to 4 do

begin

bah[j]:=TBitmap.Create;

bah[j].Transparent:=true;

bah[j].LoadFromFile(path+'\img\bah'+inttostr(j)+'.bmp');

end;

 for j:=1 to 2 do

begin

bon[j]:=TBitmap.Create;

bon[j].Transparent:=true;

bon[j].LoadFromFile(path+'\img\bon'+inttostr(j)+'.bmp');

end;

for i:=1 to 30 do

begin

pula[i].x:=0;

pula[i].y:=0;

pula[i].povorot:=0;

pula[i].visible:=false;

pula[i].ya:=0;

 end;

begin

map:=tbitmap.Create;

map.LoadFromFile(path+'\img\map.bmp');

end;

begin

buf:=tbitmap.Create;

buf.Width:=1344;buf.Height:=672;

end;

for l:=1 to 4 do

begin

block[l]:=tbitmap.create;

block[l].LoadFromFile(path+'\img\b'+inttostr(l)+'.bmp');

end;

 block[4].Transparent:=true;

novur;

end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;

  Shift: TShiftState);

var i:integer; u:boolean;

begin

if c=true then

begin

if(pov=1)and(y1>=0)and(grou[x1 div 32,(y1-2) div 32]=4)and(grou[(x1+47)div 32,(y1-2)div 32]=4)and(grou[(x1+95)div 32,(y1-2)div 32]=4

)then y1:=y1-2;

 if(pov=3)and(y1+96<=672)and(grou[x1 div 32,(y1+96) div 32]=4)and(grou[(x1+47)div 32,(y1+96)div 32]=4)and(grou[(x1+95)div 32,(y1+96)div 32]=4

)then y1:=y1+2;

  if(pov=2)and(x1+96<=1344)and(grou[(x1+96) div 32,y1 div 32]=4)and(grou[(x1+96)div 32,(y1+47)div 32]=4)and(grou[(x1+96)div 32,(y1+95)div 32]=4

)then x1:=x1+2;

   if(pov=4)and(x1>=0)and(grou[(x1-2) div 32,y1 div 32]=4)and(grou[(x1-2)div 32,(y1+47)div 32]=4)and(grou[(x1-2)div 32,(y1+95)div 32]=4

)then x1:=x1-2;

end;

if key=vk_down then

pov:=3;

 if key=vk_down then

c:=true;

if key=vk_down then

begin

inc(s);

if s>2 then s:=1;

end;

 if key=vk_left then pov:=4;

if key=vk_left then c:=true;

  if key=vk_left then

  begin

inc(s);

if s>2 then s:=1;

end;

 if key=vk_right then

pov:=2;

if key=vk_right then

c:=true;

  if key=vk_right then

begin

inc(s);

if s>2 then s:=1;

end;

if key=vk_up then

pov:=1;

if key=vk_up then

c:=true;

if key=vk_up then

  begin

inc(s);

if s>2 then s:=1;

end;

if key=vk_space then

begin

u:=false;

for i:=1 to 10 do

begin

if (time2>=15)and(u=false)and(pula[i].visible=false) then

begin

if pov=1 then begin

pula[i].x:=x1+35;

pula[i].y:=y1-26;

end;

 if pov=3 then begin

pula[i].x:=x1+35;

pula[i].y:=y1+94;

end;

if pov=2 then begin

pula[i].x:=x1+92;

pula[i].y:=y1+35;

end;

  if pov=4 then begin

pula[i].x:=x1-28;

pula[i].y:=y1+35;

end;

time2:=0;

pula[i].povorot:=pov;

pula[i].ya:=1;if zv=2 then pula[i].ya:=4;

pula[i].visible:=true;

u:=true;inc(g);

end;

end;

end;

end;

procedure TForm1.Timer1Timer(Sender: TObject);

var l,i,j,n:integer;u:boolean;

begin

 for i:=1 to 30 do

if pula[i].visible=true then buf.Canvas.Draw(pula[i].x,pula[i].y,puli[pos]);

 for l:=1 to 10 do begin

if tanks[l].live>0 then buf.Canvas.Draw(tanks[l].x,tanks[l].y,img2[tanks[l].nom,tanks[l].pov,tanks[l].s]);

if(tanks[l].live<=0)and(tanks[l].bn<5)then buf.Canvas.Draw(tanks[l].x,tanks[l].y,bah[tanks[l].bn]);

end;

   buf.Canvas.Draw(x1,y1,img[pov,s]);

for i:=18 to 20 do

for j:=0 to 2 do

grou[i,j]:=4;

 for i:=9 to 11 do

for j:=0 to 2 do

grou[i,j]:=4;

for i:=27 to 29 do

for j:=0 to 2 do

grou[i,j]:=4;

for i:=18 to 20 do

for j:=15 to 20 do

grou[i,j]:=4;bonus[6,6]:=1;

inc(time2);

pos:=5;

form1.Canvas.Draw(0,0,buf);

buf.Canvas.Draw(0,0,map);

 for i:=1 to 30 do

begin

if pula[i].povorot=2 then pos:=6;

if pula[i].povorot=4 then pos:=6;

end;

 for i:=11 to 30 do   begin

  if pula[i].visible=true then

begin

if (gauge1.Progress>0)and((pula[i].x+16)div 96=(x1+48)div 96)

and((pula[i].y+16)div 96=(y1+48)div 96)then

begin

gauge1.Progress:=gauge1.Progress-20;t:=0;

pula[i].visible:=false;

end;

if(gauge2.Visible=true)and(gauge2.Progress>0)and((pula[i].x+16)div 96=(x1+48)div 96)

and((pula[i].y+16)div 96=(y1+48)div 96) then

begin

gauge2.Progress:=gauge2.Progress-20;t:=0;

pula[i].visible:=false;

end;

end;  end;

 for i:=1 to 30 do

begin

if pula[i].visible=true then

begin

case pula[i].povorot of

1:pula[i].y:=pula[i].y-18;

2:pula[i].x:=pula[i].x+18;

3:pula[i].y:=pula[i].y+18;

4:pula[i].x:=pula[i].x-18;

end;

end;

end;

 for i:=1 to 30 do

begin

if pula[i].visible=true then

begin

 for j:=1 to 10 do

begin

if (tanks[j].live>0)and((pula[i].x+16)div 96=(tanks[j].x+48)div 96)

and((pula[i].y+16)div 96=(tanks[j].y+48)div 96)and(pula[i].ya=1)or

 (tanks[j].live>0)and((pula[i].x+16)div 96=(tanks[j].x+48)div 96)

and((pula[i].y+16)div 96=(tanks[j].y+48)div 96)and(pula[i].ya=4)

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;if pula[i].ya=4 then tanks[j].live:=tanks[j].live-3;

end;

end;

end;

if (pula[i].x+puli[6].Width<0) or (pula[i].x>form1.ClientWidth) then pula[i].visible:=false;

if (pula[i].y<0) or (pula[i].y+puli[5].Height>form1.ClientHeight) then pula[i].visible:=false;

if (grou[pula[i].x div 32,pula[i].y div 32]=3)

or(grou[pula[i].x div 32,pula[i].y div 32]=2)and(pula[i].ya=3)or(grou[pula[i].x div 32,pula[i].y div 32]=2)and(pula[i].ya=4)then

begin

n:=grou[pula[i].x div 32,pula[i].y div 32];

if (pula[i].povorot=1) or (pula[i].povorot=3) then

begin

for j:=((pula[i].x-31) div 32) to ((pula[i].x+31)div 32) do

if (j>=0)and(j<=20)and(n=grou[j,pula[i].y div 32]) then

grou[j,pula[i].y div 32]:=4;

end;

 if (pula[i].povorot=2) or (pula[i].povorot=4) then

begin

for j:=((pula[i].y-31) div 32) to ((pula[i].y+31)div 32) do

if (j>=0)and(j<=41)and(n=grou[pula[i].x div 32,j]) then

grou[pula[i].x div 32,j]:=4;

end;

pula[i].visible:=false;

end;

 if grou[pula[i].x div 32,pula[i].y div 32]=2 then

begin

pula[i].visible:=false;

end;

end;if nb>=400 then

 begin

for i:=0 to 13 do

for j:=0 to 6 do

buf.Canvas.Draw(i*96,j*96,bon[bonus[i,j]]);

end;inc(nb);

if bonus[(x1+48)div 96,(y1+48)div 96]=2 then begin

bonus[(x1+48)div 96,(y1+48)div 96]:=1;zv:=2;gauge2.Visible:=true;end;

begin

for i:=0 to 41 do

for j:=0 to 20 do

buf.Canvas.Draw(i*32,j*32,block[grou[i,j]]);

end;if gauge2.Progress<=0 then gauge2.Visible:=false;if gauge2.Visible=true then gauge1.Progress:=100;

if gauge1.Progress<=0 then begin

timer1.Enabled:=false;showmessage('Âû ïîãèáëè.Òàíêîâ ïðîòèâíèêà óíè÷åîæåíî '+inttostr(m)+' Âûñòðåëîâ ñäåëàíî '+inttostr(g));novur;

for i:=1 to 30 do pula[i].visible:=false;end;

inc(nt);

if (nt=200)and(kol<10)then

begin

nt:=0;inc(kol);

if (kol=4)or(kol=7)or(kol=10)then tanks[kol].x:=3*96;

if (kol=5)or(kol=8)then tanks[kol].x:=6*96;

if (kol=6)or(kol=9)then tanks[kol].x:=9*96;

tanks[kol].y:=0;tanks[kol].nom:=random(2)+1;

if tanks[kol].nom=1 then begin

tanks[kol].live:=3;tanks[kol].sp:=2;end;

if tanks[kol].nom=2 then begin

tanks[kol].live:=2;tanks[kol].sp:=4;end;

end;if kol>=10 then begin

u:=true;

for i:=1 to 10 do

if tanks[i].live>0 then u:=false;

if u=true then begin

timer1.Enabled:=false;

showmessage('Ïîçäðàâëÿåì!Âû ïîáåäèëè!Âñå òàíêè ïðîòèâíèêà óíè÷òîæåíû.Âûñòðåëîâ ñäåëàíî '+inttostr(g));

for i:=1 to 30 do pula[i].visible:=false;

novur;end;end;

if gauge1.Progress<100 then begin

t:=t+1;if t>=60 then gauge1.Progress:=gauge1.Progress+1;end;

 if gauge2.Progress<100 then begin

t:=t+1;if t>=60 then gauge2.Progress:=gauge2.Progress+10;end;

inc(k);if k>3 then k:=1;

 for i:=1 to 10 do

 begin

 inc(tanks[i].s);  tanks[i].time:=tanks[i].time+1;

if tanks[i].s>2 then tanks[i].s:=1;inc(tanks[i].bn);

end;

 for i:=1 to 10 do

 begin

begin

if(tanks[i].live>0) then

begin

u:=false;

for j:=11 to 30 do

begin

if (tanks[i].time>=30)and(u=false)and(pula[j].visible=false) then

begin

if tanks[i].pov=1 then begin

pula[j].x:=tanks[i].x+36;

pula[j].y:=tanks[i].y-26;

end;

 if tanks[i].pov=3 then begin

pula[j].x:=tanks[i].x+36;

pula[j].y:=tanks[i].y+94;

end;

if tanks[i].pov=2 then begin

pula[j].x:=tanks[i].x+92;

pula[j].y:=tanks[i].y+36;

end;

  if tanks[i].pov=4 then begin

pula[j].x:=tanks[i].x-28;

pula[j].y:=tanks[i].y+36;

end;

tanks[i].time:=0;

pula[j].povorot:=tanks[i].pov;

if tanks[i].nom=1 then pula[j].ya:=2;

if tanks[i].nom=2 then pula[j].ya:=3;

 pula[j].visible:=true;

u:=true;

end;

end;

end;end;

case tanks[i].pov of

1: if(tanks[i].y<=0)or(grou[tanks[i].x div 32,(tanks[i].y-2) div 32]=k)or(grou[(tanks[i].x+47)div 32,(tanks[i].y-2)div 32]=k)or(grou[(tanks[i].x+95)div 32,(tanks[i].y-2)div 32]=k

)then tanks[i].pov:=random(4)+1;

3: if (tanks[i].y+96>=672)or(grou[tanks[i].x div 32,(tanks[i].y+96) div 32]=k)or(grou[(tanks[i].x+47)div 32,(tanks[i].y+96)div 32]=k)or(grou[(tanks[i].x+95)div 32,(tanks[i].y+96)div 32]=k

)then  tanks[i].pov:=random(4)+1;

2: if (tanks[i].x+96>=1344)or(grou[(tanks[i].x+96) div 32,tanks[i].y div 32]=k)or(grou[(tanks[i].x+96)div 32,(tanks[i].y+47)div 32]=k)or(grou[(tanks[i].x+96)div 32,(tanks[i].y+95)div 32]=k

)then  tanks[i].pov:=random(4)+1;

4: if (tanks[i].x<=0)or(grou[(tanks[i].x-2) div 32,tanks[i].y div 32]=k)or(grou[(tanks[i].x-2)div 32,(tanks[i].y+47)div 32]=k)or(grou[(tanks[i].x-2)div 32,(tanks[i].y+95)div 32]=k

)then  tanks[i].pov:=random(4)+1;

end;

 case tanks[i].pov of

1: if(tanks[i].y>=0)and(grou[tanks[i].x div 32,(tanks[i].y-2) div 32]=4)and(grou[(tanks[i].x+47)div 32,(tanks[i].y-2)div 32]=4)and(grou[(tanks[i].x+95)div 32,(tanks[i].y-2)div 32]=4

)then tanks[i].y:=tanks[i].y-tanks[i].sp;

3: if(tanks[i].y+96<=672)and(grou[tanks[i].x div 32,(tanks[i].y+96) div 32]=4)and(grou[(tanks[i].x+47)div 32,(tanks[i].y+96)div 32]=4)and(grou[(tanks[i].x+95)div 32,(tanks[i].y+96)div 32]=4

)then tanks[i].y:=tanks[i].y+tanks[i].sp;

2: if(tanks[i].x+96<=1344)and(grou[(tanks[i].x+96) div 32,tanks[i].y div 32]=4)and(grou[(tanks[i].x+96)div 32,(tanks[i].y+47)div 32]=4)and(grou[(tanks[i].x+96)div 32,(tanks[i].y+95)div 32]=4

)then tanks[i].x:=tanks[i].x+tanks[i].sp;

4: if(tanks[i].x>=0)and(grou[(tanks[i].x-2) div 32,tanks[i].y div 32]=4)and(grou[(tanks[i].x-2)div 32,(tanks[i].y+47)div 32]=4)and(grou[(tanks[i].x-2)div 32,(tanks[i].y+95)div 32]=4

)then tanks[i].x:=tanks[i].x-tanks[i].sp;

end;

end;

end;

procedure tform1.novur;

var i,j,n:integer;

begin

x1:=6*96;pov:=1;time2:=0;t:=0;zv:=1;nb:=0;

y1:=6*96;s:=1;timer1.Enabled:=true;m:=0;g:=0;gauge2.Visible:=false;

 for i:=1 to 10 do

begin

tanks[i].nom:=1;

tanks[i].time:=0;

tanks[i].pov:=3;

tanks[i].s:=1;

tanks[i].live:=0;

tanks[i].x:=-1;

tanks[i].y:=-1;

tanks[i].pov:=3;

tanks[i].sp:=2;

tanks[i].bn:=6;

end;

  tanks[2].x:=6*96;

tanks[2].y :=0;

 tanks[2].nom:=random(2)+1;

if tanks[2].nom=2 then begin tanks[2].live:=2;tanks[2].sp:=4;end;

 if tanks[1].nom=2 then begin tanks[1].live:=2;tanks[1].sp:=4;end;

if tanks[2].nom=1 then begin tanks[2].live:=3;tanks[2].sp:=2;end;

 tanks[1].x:=3*96;

tanks[1].y :=0;

 tanks[1].nom:=random(2)+1;;

if tanks[1].nom=1 then begin tanks[1].live:=3;tanks[1].sp:=2;end;

tanks[3].x:=9*96;

tanks[3].y :=0;

 tanks[3].nom:=random(2)+1;;

if tanks[3].nom=1 then begin tanks[3].live:=3;tanks[3].sp:=2;end;

if tanks[3].nom=2 then begin tanks[3].live:=2;tanks[3].sp:=4;end;

c:=false; k:=1;kol:=3;nt:=0;gauge1.Progress:=100;

  for i:=0 to 41 do

for j:=0 to 20 do

grou[i,j]:=4;

for i:=0 to 13 do

for j:=0 to 6 do

bonus[i,j]:=1;

randomize;

n:=0;

while n<=22 do

begin

x:=random(14)*3;

y:=random(7)*3;

b:=(random(3))+1;

for i:=x to x+2 do

for j:=y to y+2 do

grou[i,j]:=b;

inc(n);

end;

begin

i:=random(14);

j:=random(7);

if(bonus[i,j]=1)and(grou[i*3,j*3]=4)then bonus[i,j]:=2;

end;

end;

end.

 

Добавить комментарий


Защитный код
Обновить

Комментарии  

0 #2 Ксeния 10.11.2016 06:39
:-) ;-) ;-)
Цитировать
0 #1 Ксния 10.11.2016 06:32
:-) :-) :-)
Цитировать