unit Paint;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls;
type
TPaint =
class
private
Colors:
array [0..7]
of array [0..7]
of Boolean;
Size, Space: Integer;
PenBlack, PenWhite: TPen;
BrushBlack, BrushWhite: TBrush;
protected
public
constructor Create(PaintBox: TPaintBox);
destructor Destroy();
override;
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-100)
div 8;
self.Space := (PaintBox.Width - PaintBox.Height + 100)
div 2;
self.PenBlack := TPen.Create;
self.PenWhite := TPen.Create;
self.BrushBlack := TBrush.Create;
self.BrushWhite := TBrush.Create;
self.PenBlack.Color := clblack;
self.PenWhite.Color := clwhite;
self.PenBlack.Width := 5;
self.PenWhite.Width := 5;
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;
if Bool
then
begin
Bool := false;
end else
begin
Bool := true;
end;
end;
end;
destructor TPaint.Destroy;
begin
self.PenBlack.Free;
self.PenWhite.Free;
self.BrushBlack.Free;
self.BrushWhite.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(Space+X*Size,50+Y*Size,Space+(X+1)*Size,50+(Y+1)*Size));
end;
end;
end;
end.