дал мне друг книгу с программами вот одна из них - убить рожу:
| Код | unit kill_facePAS; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) Timer1: TTimer; procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); private { Private declarations } public { Public declarations }
procedure PaintFace(x,y: integer); //ðèñóåì ðîæó procedure EraseFace(x,y: integer); //ñòèðàåì ðîæó end; var Form1: TForm1;
fx,fy:integer;//коордиты рожи n:integer=0;//kolvo щелчков по форме мышью p:integer=0;//kolvo popadaniy
implementation
{$R *.dfm}
procedure tform1.PaintFace(x,y:integer); begin with canvas do begin Pen.Color:=clblack; Brush.Color:=clyellow; //рисуем рожу ellipse(x,y,x+30,y+30); ellipse(x+9,y+10,x+11,y+13); ellipse(x+19,y+10,x+21,y+13); arc(x+4,y+4,x+26,y+26,x,y+20,x+30,y+20); end; end;
procedure tform1.EraseFace(x,y:integer); begin with canvas do begin Pen.Color:=clbtnface; Brush.Color:=clbtnface;
//стираем ellipse(x,y,x+30,y+30);
end; end;
procedure TForm1.FormCreate(Sender: TObject); begin //исходное положение рожи fx:=100;fy:=100; randomize; end;
procedure TForm1.Timer1Timer(Sender: TObject); begin EraseFace(fx,fy); //каждый раз при таймере новое положение рожи fx:=random(clientwidth-30); fy:=random(clientheight-30); paintface(fx,fy); end;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin inc(n);//подсчитываем сколько раз игрок нажал на мышь if (x>fx) and (x<fx+30) and (y>fy) and (x<fy+30) then begin inc(p);//попадания end; if n=10 then begin timer1.Enabled:=false; caption:=inttostr(p); eraseface(fx,fy); end; end; end.
|
у меня вопрос, а что не так раз программа не правильно считывает количество попаданий, интервал таймера изменял всё тоже самое, но только если в одну и ту же точку попасть при медленном таймере то все попадания сосчитаются?? что за глюки - на фига мне эти муки?? |