unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TKarte =
Array [ 0..19, 0..14 ]
of Byte;
TForm1 =
class(TForm)
Button1: TButton;
Procedure Render();
procedure FormPaint(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
Karte : TKarte;
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Procedure TForm1.Render();
var
X , Y : Byte;
begin
for Y := 0
to 14
do
begin
for X := 0
to 19
do
begin
Case Karte[ X, Y ]
of
0:
begin
Canvas.Brush.Color:= clWhite;
Canvas.Pen.Color:= clWhite;
end;
1:
begin
Canvas.Brush.Color:= clGreen;
Canvas.Pen.Color:= clBlack;
end;
end;
Canvas.Rectangle( X * 32, Y * 32, X * 32 + 32, Y * 32 + 32 );
end;
end;
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
Render();
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Render();
end;
procedure TForm1.Button1Click(Sender: TObject);
var Y2,X2:byte;
begin
RANDOMIZE();
Y2 := Random(15);
X2 := Random(20);
Karte[ X2, Y2 ]:= 1;
Render();
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
FeldX, FeldY : Byte;
begin
if ( X > 639 )
or ( X < 0 )
then Exit;
if ( Y > 479 )
or ( Y < 0 )
then Exit;
FeldX := X
div 32;
FeldY := Y
div 32;
Form1.Caption:= inttostr(FeldX)+'
|'+inttostr(FeldY);
end;
end.