Hier mal meins.
Die Klassen:
Delphi-Quellcode:
TWorld = class
private
FWorldHeight: Integer;
FWorldWidth: Integer;
FBufferArray: array of array of TCreature;
FWorldArray: array of array of TCreature;
public
constructor Create(WorldHeight, WorldWidth: Integer);
destructor Destroy; override;
end;
TCreature = class
private
FName: string;
public
end;
TGround = class(TCreature)
private
public
end;
TSand = class(TGround)
private
public
constructor Create;
destructor Destroy;
end;
Und hier die Klasse TSand:
Delphi-Quellcode:
constructor TSand.Create;
begin
inherited Create;
FName := 'Sand';
end;
Sowie die Klasse TWorld:
Delphi-Quellcode:
constructor TWorld.Create(WorldHeight, WorldWidth: Integer);
var
i: Integer;
j: Integer;
ArrayLength: Integer;
begin
FWorldHeight := WorldHeight;
FWorldWidth := WorldWidth;
ArrayLength := WorldHeight * WorldWidth;
SetLength(FBufferArray, ArrayLength);
SetLength(FWorldArray, ArrayLength);
for i := 0 to FWorldHeight - 1 do
for j := 0 to FWorldWidth - 1 do
begin
FBufferArray[i][j] := TGround.Create;
end;
end;