While writing my game in BlitzMax and using Object Oriented Programming, I was wondering about something. (I think this still goes under general discussion as the topic is a general one and not restricted to BlitzMax.)
I have defined a type tGame. In this type, I use objects of type tEntity. tGame runs the world, of which tEntity objects are a part. So, information such as the size of the world is part of tGame, and tGame tells tEntity objects to move.
My question is, in the move method of tEntity, how does tEntity know the edge of the world has been reached? (In other words, how does it get to know about the size of the world that is stored in tGame.)
I am thinking about creating a tWorld type, and using it as a singleton. Then in the move method of tEntity I could do:
I am interested to know how others would set up this kind of structure / information flow.
I have defined a type tGame. In this type, I use objects of type tEntity. tGame runs the world, of which tEntity objects are a part. So, information such as the size of the world is part of tGame, and tGame tells tEntity objects to move.
My question is, in the move method of tEntity, how does tEntity know the edge of the world has been reached? (In other words, how does it get to know about the size of the world that is stored in tGame.)
I am thinking about creating a tWorld type, and using it as a singleton. Then in the move method of tEntity I could do:
If (x >= tWorld.getInstance().getWidth()) Then DebugLog("reached end of world") End If
I am interested to know how others would set up this kind of structure / information flow.