I can't find a 'clean' way around a problem where types need to refer to each other. BlitzMax complains about duplicate type definitions.
In a space simulation program, I have created T_Thing which is the base of all objects that can exist in the universe. One of its methods is Draw which takes a T_Viewport parameter. The T_Viewport type provides scaling functions that T_Thing needs in order to know how and where to draw itself.
T_Thing and T_Viewport are definied in separate files. Within T_Thing it is necessary to Import "T_Viewport.bmx" so that the type is available.
All is OK so far.
Now I want T_Viewport to be able to track a given T_Thing so that the object is at the centre of the display and this automatically updates to the latest object position each draw cycle.
I attempt to do this by adding a Field to T_Viewport called TrackThing which is of type T_Thing. Now T_Viewport must contain Import "T_Thing.bmx". But then BlitzMax complains about a duplicate definition of T_Viewport.
To simplify the example, consider the following which compiles without error as the two types are definined in the one file:
Version1.bmx
Now separate the types:
Version2A.bmx
Version2B.bmx
Trying to build this starting with file Version2A.bmx gives "Compile Error - Duplicate identifier "B".
In general, it appears that BlitzMax cannot provide two types defined in separate files that make reference to each other.
I can of course work around the problem by having something outside of the viewport set the centre X, Y from the object but it would be so much nicer for the viewport to be able to know what it is centred upon.
Has anybody seen a similar problem and either solved it or determined that this is a language limitation ?
In a space simulation program, I have created T_Thing which is the base of all objects that can exist in the universe. One of its methods is Draw which takes a T_Viewport parameter. The T_Viewport type provides scaling functions that T_Thing needs in order to know how and where to draw itself.
T_Thing and T_Viewport are definied in separate files. Within T_Thing it is necessary to Import "T_Viewport.bmx" so that the type is available.
All is OK so far.
Now I want T_Viewport to be able to track a given T_Thing so that the object is at the centre of the display and this automatically updates to the latest object position each draw cycle.
I attempt to do this by adding a Field to T_Viewport called TrackThing which is of type T_Thing. Now T_Viewport must contain Import "T_Thing.bmx". But then BlitzMax complains about a duplicate definition of T_Viewport.
To simplify the example, consider the following which compiles without error as the two types are definined in the one file:
Version1.bmx
Strict Type A Field Name:String Field Income:Int Field Friend:B End Type Type B Field Name:String Field Height:Float Field Associate:A End Type
Now separate the types:
Version2A.bmx
Strict Import "Version2B.bmx" Type A Field Name:String Field Income:Int Field Friend:B End Type
Version2B.bmx
Strict Import "Version2A.bmx" Type B Field Name:String Field Height:Float Field Associate:A End Type
Trying to build this starting with file Version2A.bmx gives "Compile Error - Duplicate identifier "B".
In general, it appears that BlitzMax cannot provide two types defined in separate files that make reference to each other.
I can of course work around the problem by having something outside of the viewport set the centre X, Y from the object but it would be so much nicer for the viewport to be able to know what it is centred upon.
Has anybody seen a similar problem and either solved it or determined that this is a language limitation ?