Sign in to follow this  
thedevdan

Since games have strict rules...

Recommended Posts

thedevdan    210
...I'm having a hard time seeing how to fit them into the OO paradigm. Here is my problem: I don't see how you can delegate (not literally) actions to different objects, because their actions would have to be bounds-checked. And if they need to be bounds-checked, they need to be bounds-correctable, which would mean friendship. In other words: How can you safely let each object do it's own thing without having to make sure what they do is safe?

Share this post


Link to post
Share on other sites
Zahlman    1682
Let objects know about the things which contain them.

When the objects are 'doing their own thing', have them ask the containing object for permission, if their location changes. It could be as simple as having each ContainerObject provide a "Location ContainerObject.clampToInterior(Location)" method. (Or possibly a void return type, if your Location type is mutable.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this