I'm having some problems with my objects. Simply put I need my objects to know of eachother.

Suppose have the following code. (/////////// marks a new unit)

[pascal]
unit windowUnit;

interface

uses worldUnit, (someMoreUnits)

type TGameWindow = class(TObject)
private
(..)
public
(..)
world : TWorld;
end;

var
Window : TGameWindow;

///////////////////
unit worldUnit;

interface

uses spriteUnit, (someMoreUnits);


type TWorld = class(TObject)
private
(..)
public
Joe : TSprite;
height : word;
width : word;
(...)
end;

/////////////////////////
unit spriteUnit;

interface

uses (someMoreUnits)

TDirection = (dLeft, dRight, dUp, dDown, dNone);

type TSprite = class(Tobject)
private
x : single;
y : single;
direction : TDirection;
(etc)
public
(etc)
procedure move();
end;

(etc)

procedure TSprite.move();
begin
if x < 0 then direction := dRight
else if x > window.world.width then direction := dLeft;

if y < 0 then direction := dUp
else if y > window.world.height then direction := dDown;
end;
[/pascal]

Ok, so I have a world that gets created in a window and in the world we have Joe. Suppose the world gives the order to move Joe from point A to B, then the move procedure of the sprite would be called.

Here's where the problem arises. Joe has to know what the limits are of the world, otherwise he'd fall off. At some point he'll also want to know where he can walk and where he can't. Point is, currently Joe doesn't know of the world. Variable Window isn't known to him.

How can I solve this? I've tried several things, but most of the time I got problems with circular referencing my units :?

Thanks.