1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
procedure TForm1.ZoneAffMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
if (ssLeft in Shift) then
begin
Depl.X:= (CurPos0.X-X); // Depl = déplcement de la souris en pixels // tu va du point A (OnMouseMouve) et tu te déplaces Jusqu'au point B (de X,Y) donc pas besoin de cumulé dans OnMouseUp. Le déplacement se cumule déja ici
Depl.Y:= (CurPos0.Y-Y);
CurPos0.X:= X;
CurPos0.Y:= Y;
ZoneAff.DoOnPaint;
end;
end;
procedure TForm1.ZoneAffMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Dec0.X:= Dec0.X-Depl.X;
Dec0.Y:= Dec0.Y-Depl.Y;
//Depl.X:= 0;
//Depl.Y:= 0;
end;
// Note XX et YY sont des varibales globale
procedure TForm1.FormCreate(Sender: TObject);
begin
DataLoaded := False;
CapDeg:= 0; // Initialisation Cap
// sincos(DegARad*CapDeg, sinCap, cosCap);
Org.X:= ZoneAff.Width / 2-640;
Org.Y:= ZoneAff.Height / 2-640;
XX := Org.X;
YY := Org.Y;
PivotP.X :=640;
PivotP.Y :=640;
end;
procedure TForm1.ZoneAffPaint(Sender: TObject);
begin
Load;
BGLViewPort(ZoneAff.Width, ZoneAff.Height, BGRABlack);
//XX:= Org.X+Depl.X;
//YY:= Org.Y+Depl.Y;
XX:= XX-Depl.X;
YY:= YY-Depl.Y;
PivotP.X := PivotP.X + Depl.X;
PivotP.Y := PivotP.Y + Depl.Y;
Edit1.Text:= FloatToStr(XX);
Edit2.Text:= FloatToStr(YY);
Edit3.Text:= FloatToStr(PivotP.X);
Edit4.Text:= FloatToStr(PivotP.Y);
Carte.DrawAngle(XX, YY, CapDeg,PivotP, true); // False); // Déplcemenr et rotation de la Carte
Cible.Draw(ZoneAff.Width/2-32, ZoneAff.Height/2-32, $FF); // Affichage de la cible
Pivot.Draw(PivotP.X-32, PivotP.Y-32, $FF); // Affichage de la cible
ZoneAff.SwapBuffers;
end; |
Partager