unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ImgList, StdCtrls;
type
TForm1 =
class(TForm)
Image1: TImage;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
procedure ReDraw();
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
Spielfeld:
array[0..50,0..50]
of integer;
implementation
{$R *.dfm}
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
for a:=0
to 10
do
begin
for b:=0
to 10
do
begin
Image1.Canvas.Pixels[x*10+a,y*10+b]:=clred;
end;
end;
end;
if Spielfeld[x,y]= 2
then
begin
for a:=0
to 10
do
begin
for b:=0
to 10
do
begin
Image1.Canvas.Pixels[x*10+a,y*10+b]:=clblue;
end;
end;
end;
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
randomize;
Spielfeld[random(50),random(50)]:=2;
Spielfeld[random(50),random(50)]:=1;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ReDraw;
end;
end.