unit schif_u;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, Buttons;
type
TForm1 =
class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label4: TLabel;
BitBtn3: TBitBtn;
Image1: TImage;
Edit4: TEdit;
Edit5: TEdit;
Button1: TButton;
Label5: TLabel;
Label6: TLabel;
Panel1: TPanel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure Image1Click(Sender:TObject);
procedure Image1MouseMove(Sender:TObject; Shift: TShiftstate;
x,y:integer);
private MausDarfKlicken: boolean;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
v,Spalte,Zeile:integer;
implementation
{$R *.DFM}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Image1Click(Sender:TObject);
var x,y:integer;
begin
with Image1.canvas
do
if MausDarfKlicken
then
begin
x:=(spalte*30)-15;
y:=(zeile*30)-15;
brush.color:=clgreen;
floodfill(x,y,clblack,fsborder);
end;
end;
procedure TForm1.Image1MouseMove(Sender:TObject; Shift: TShiftstate;
x,y:integer);
begin
with Image1.canvas
do
x:=(spalte*30)-15;
y:=(zeile*30)-15;
if (Image1.Canvas.Pixels[x,y]=clwhite)
then
begin
MausDarfKlicken:=false;
end
else
begin
MausDarfKlicken:=true;
end;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
var x,y,n:integer;
begin
with image1.Canvas
do
begin
randomize;
brush.color:=clwhite;
pen.Color:=clblack;
rectangle(0,0,width,height);
pen.Color:=clblack;
for n:=1
to 10
do
begin
moveto(0,n*30);
lineto(305,n*30);
end;
for n:=1
to 10
do
begin
moveto(n*30,0);
lineto(n*30,305);
end;
Spalte:= random(10)+1;
Zeile:= random(9)+1;
x:=(spalte*30)-15;
y:=(zeile*30)-15;
pixels[x,y]:=clred;
edit4.text:=inttostr(spalte);
edit5.text:=inttostr(zeile);
brush.color:=clwhite;
floodfill(x,y,clblack,fsborder);
BitBtn2.enabled:=false;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
v:=0;
with Image1.canvas
do
begin
pen.color:=clblack;
brush.color:=clwhite;
rectangle(0,0,width,height);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var Sp,Ze,x,y:integer;
begin
with image1.Canvas
do
begin
Edit3.text:='
';
v:=v+1;
{Sp:=StrToInt(Edit1.text);
Ze:=StrToInt(Edit2.text);}
x:=(sp*30)-15;
y:=(ze*30)-15;
brush.color:=clgreen;
floodfill(x,y,clblack,fsborder);
Edit3.text:=inttostr(v);
if {(Sp=Spalte) and (Ze=Zeile)} MausDarfKlicken=true
then
begin
Panel1.caption:='
Schiff versenkt!!';
BitBtn3.enabled:=false;
BitBtn2.enabled:=true;
button1.enabled:=false;
Panel1.visible:=true;
brush.color:=clyellow;
floodfill(x,y,clblack,fsborder);
end;
end;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var x,y,n:integer;
begin
v:=0;
with image1.Canvas
do
begin
randomize;
brush.color:=clwhite;
pen.Color:=clblack;
rectangle(0,0,width,height);
pen.Color:=clblack;
for n:=1
to 10
do
begin
moveto(0,n*30);
lineto(305,n*30);
end;
for n:=1
to 10
do
begin
moveto(n*30,0);
lineto(n*30,305);
end;
Spalte:= random(10)+1;
Zeile:= random(9)+1;
x:=(spalte*30)-15;
y:=(zeile*30)-15;
pixels[x,y]:=clred;
{edit4.text:=inttostr(spalte);
edit5.text:=inttostr(zeile); }
begin
if MausDarfKlicken=true
then
brush.color:=clwhite;
floodfill(x,y,clblack,fsborder);
end;
BitBtn2.enabled:=false;
button1.enabled:=true;
Edit1.text:='
';
Edit2.text:='
';
Edit3.text:='
';
Panel1.visible:=false;
end;
end;
end.