unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ImgList, StdCtrls;
type
TForm1 =
class(TForm)
Image1: TImage;
Button2: TButton;
Button1: TButton;
Button3: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
Spielfeld:
array[0..50,0..50]
of integer;
procedure ReDraw();
procedure Clear();
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Clear;
var
x,y:longint;
begin
Image1.Canvas.Brush.Color:=clwhite;
Image1.Canvas.Rectangle(0,0,Image1.Width,Image1.Height);
for x:=0
to 50
do
begin
for y:=0
to 50
do
begin
SpielFeld[x,y]:=0;
end;
end;
end;
procedure TForm1.ReDraw;
var
x,y:longint;
a,b:longint;
begin
for x:=0
to 50
do
begin
for y:=0
to 50
do
begin
if Spielfeld[x,y]= 1
then
begin
Image1.Canvas.Brush.Color:=clred;
Image1.Canvas.Rectangle(x*10,y*10,x*10+10,y*10+10);
end;
if Spielfeld[x,y]= 2
then
begin
Image1.Canvas.Brush.Color:=clblue;
Image1.Canvas.Rectangle(x*10,y*10,x*10+10,y*10+10);
end;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
clear;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
a,b:longint;
begin
Clear;
end;
{function ran:boolean;
begin
if random(2)= 1 then
result := true
else result:=false;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
I:longint;
a,b:integer;
begin
randomize;
a:=Random(50);
b:=Random(50);
for i:=10 to 200 do
begin
if ran then
if ran then
b:=b+1
else
b:=b-1
else
if ran then
a:=a+1
else
a:=a-1;
SpielFeld[a,b]:=1;
end;
SpielFeld[a,b]:=1;
Redraw;
end;}
end.