В игре есть счетчик, но вместо одного бала, при попадании, прибавляет 6.
Подскажите как исправить7
Подскажите как исправить7
Код:
procedure TForm2.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
If key=37 then men.Left :=men.Left-10;//влево
If key=39 then men.Left :=men.Left+10;//вправо
If key=32 then //нажат пробел
Begin
pula.Visible :=true;
pula.Left:=men.Left ;
pula.Top:=men.Top-pula.Height ;
timer2.interval:=10;
End;
end;
procedure TForm2.Timer1Timer(Sender: TObject);
begin
Samolet.Left :=Samolet.Left +1;
If Samolet.Left >300 Then Samolet.Left :=-20;
end;
procedure TForm2.Timer2Timer(Sender: TObject);
var
x,y,h,w:integer;// координаты и размеры пули
x0,y0,h0,w0 :integer; // координаты и размеры самолета
begin
pula.Top:=pula.Top-10;
If pula.top<0 then
Begin
timer2.Interval :=0;
pula.Visible :=false;
End;
x:=pula.left; y:=pula.Top;
w:=pula.Width ; h:=pula.Height ;
x0:=samolet.Left ; y0:=samolet.Top;
w0:=samolet.Width ;h0:=samolet.Height ;
if (x+w>x0) and (x<x0+w0) and (y+h>y0) and (y<y0+h0) then
result.Caption :=inttostr(strtoInt(result.Caption)+1) ;
end;
procedure TForm2.Timer3Timer(Sender: TObject);
begin
If Bomba.Visible =False Then
Begin
Bomba.Visible :=True;
Bomba.Left :=Samolet.Left+5 ;
Bomba.Top:=Samolet.Top+5;
End
Else
Begin
Bomba.Top:=Bomba.Top+1;
If Bomba.top>men.Top+30 Then Bomba.Visible :=False;
End ;
end;