unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, pngimage, pngextra, pnglang, ExtCtrls, StdCtrls;
type
TForm2 =
class(TForm)
Image1: TImage;
Timer1: TTimer;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Körper;
procedure update;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
implementation
var
Form2: TForm2;
TYPE Tfeld =
record
Bild: TImage;
Name:
String;
End;
var feld:
array [1..17,1..13]
of Tfeld;
var x,y : integer;
TYPE Tsnake =
record
x1 : integer;
y1 : integer;
end;
var snake:
array [1..12]
of Tsnake;
var
Rrichtung: byte;
{$R *.dfm}
procedure init;
var i : integer;
begin
i:=1;
randomize;
for x:=1
to 13
do
begin;
for y:=1
to 17
do
begin;
feld[x,y].
Name := '
Gras';
feld[x,y].Bild := Timage.create(Form2);
feld[x,y].Bild.parent := Form2;
feld[x,y].Bild.top := x*50;
feld[x,y].Bild.left := y*50;
feld[x,y].Bild.Picture.LoadFromFile('
images/gras.PNG');
end;
end;
for y:= 1
to 17
do
begin;
for x:=1
to 13
do
begin;
If (y = 1)
or (y = 17)
then
begin;
feld[x,y].
Name := '
Wand';
feld[x,y].Bild := Timage.create(Form2);
feld[x,y].Bild.parent := Form2;
feld[x,y].Bild.top := x*50;
feld[x,y].Bild.left := y*50;
feld[x,y].Bild.Picture.LoadFromFile('
images/wand-hoch.PNG')
end;
end;
end;
for x:= 1
to 13
do
begin;
for y:=1
to 17
do
begin;
If (x = 1)
or(x = 13)
then
begin;
feld[x,y].
Name := '
Wand';
feld[x,y].Bild := Timage.create(Form2);
feld[x,y].Bild.parent := Form2;
feld[x,y].Bild.top := x*50;
feld[x,y].Bild.left := y*50;
feld[x,y].Bild.Picture.LoadFromFile('
images/wand-breit.PNG')
end;
end;
end;
end;
begin
for x:=6
to 9
do
begin
y:=9;
feld[x,y].
Name := '
Snake-Körper';
feld[x,y].Bild := Timage.create(Form2);
feld[x,y].Bild.parent := Form2;
feld[x,y].Bild.top := x*50;
feld[x,y].Bild.left := y*50;
feld[x,y].Bild.Picture.LoadFromFile('
images/körper.PNG');
snake[i].x1:=x;
snake[i].y1:=y;
i:=i+1;
end;
x:= random(14)+2;
y:= random(10)+2;
begin
feld[x,y].
Name := '
Apfel';
feld[x,y].Bild := Timage.create(Form2);
feld[x,y].Bild.parent := Form2;
feld[x,y].Bild.top := x*50;
feld[x,y].Bild.left := y*50;
feld[x,y].Bild.Picture.LoadFromFile('
images/apfel.PNG');
end;
x:=0;
y:=0;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
Form2.DoubleBuffered:=True;
init;
end;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
Button1.Visible:=false;
TForm2.Timer1Timer;
end;
end.