Objects and relationships

BlitzMax Forums/BlitzMax Beginners Area/Objects and relationships

Ant(Posted 2005) [#1]
Hi! I have created a description of objects in my world using types/instances. I now want to link objects together (ie button A will reference door D and execute its move code) so I can set up behaviours between objects.

So when I have created an instance of each type, how do I go about this?If I create 'button A', do I create a pointer to Door D, or is just a case of naming Door D directly within Button A (and just have an interactor field within the button type)? Apologies if this is an obvious question, I'm getting to grips with OOP and Blitz and I'm always a little worried about getting into bad habits.
Thanks for any help as always


Chris C(Posted 2005) [#2]
Type worldobject
    Field x#,y#,z#,name$
    Field target:worldobject
End Type

Global wobs:worldobject[10]

wobs[0]=New worldobject
wobs[0].name$="Door 1"

wobs[1]=New worldobject
wobs[1].name="Switch 1"
wobs[1].target=wobs[0]

Print wobs[1].name+" targets "+wobs[1].target.name

is how i'd do it...