123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- unit rectactionunit;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, mapactionunit, mapchangeunit;
- type
- { TRectAction }
- TRectAction = class(TMapAction)
- private
- StartX, StartY: Integer;
- MapChange: TMapChange;
- function GetMapChange: TMapChange; override;
- public
- constructor Create;
- procedure Start(X, Y); virtual; override;
- procedure Continue(X, Y); virtual; override;
- destructor Destroy; override;
- end;
- implementation
- uses
- Math;
- { TRectAction }
- function TRectAction.GetMapChange: TMapChange;
- begin
- GetMapChange := MapChange;
- end;
- constructor TRectAction.Create;
- begin
- MapChange := TMapChange.Create;
- end;
- procedure TRectAction.Start(X, Y);
- begin
- StartX := X;
- StartY := Y;
- end;
- procedure TRectAction.Continue(X, Y);
- begin
- MapChange.Left := Max(0, StartX - 1);
- MapChange.Top := Max(0, StartY - 1);
- MapChange.Right := Min(X + 1, Map.Integers['width'] - 1);
- MapChange.Bottom := Min(Y + 1, Map.Integers['height'] - 1);
- end;
- destructor TRectAction.Destroy;
- begin
- MapChange.Free;
- inherited Destroy;
- end;
- end.
|