unit Paint;
interface
uses Graphics, Classes, ExtCtrls;
type
TPaint =
class
private
Colors:
array [0..7]
of array [0..7]
of Boolean;
Size: Integer;
PenBlack, PenWhite: TPen;
BrushBlack, BrushWhite: TBrush;
protected
public
constructor Create(PaintBox: TPaintBox);
destructor Destroy();
procedure Paint(C: TCanvas);
end;
implementation
uses MainGame;
constructor TPaint.Create(PaintBox: TPaintBox);
var
X,Y: Integer;
Bool: Boolean;
begin
inherited Create();
self.Size := PaintBox.Height
div 8;
self.PenBlack.Color := clblack;
self.PenWhite.Color := clwhite;
self.PenBlack.Width := 1;
self.PenWhite.Width := 1;
self.BrushBlack.Color := clBlack;
self.BrushWhite.Color := clWhite;
Bool := true;
for X := 0
to Length(Colors)-1
do
begin
for Y := 0
to Length(Colors[X])-1
do
begin
Colors[X,Y] := Bool;
if Bool
then
begin
Bool := false;
end else
begin
Bool := true;
end;
end;
end;
end;
destructor TPaint.Destroy();
begin
inherited Destroy;
self.Free;
end;
procedure TPaint.Paint(C: TCanvas);
var
X,Y: Integer;
begin
for X := 0
to Length(self.Colors)-1
do
begin
for Y := 0
to Length(self.Colors[X])-1
do
begin
if self.Colors[X,Y]
then
begin
C.Pen := self.PenWhite;
C.Brush := self.BrushWhite;
end else
begin
C.Pen := self.PenBlack;
C.Brush :=self.BrushBlack;
end;
C.Rectangle(Rect(X*Size,Y*Size,(X+1)*Size,(Y+1)*Size));
end;
end;
end;
end.