• Advertisement

Archived

This topic is now archived and is closed to further replies.

OOP Design

This topic is 5831 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve read an entire c++ book, making sure I understood everything in it as I went. But I''m still not sure on how I should be implementing things. My current project (pong) currently uses 2 classes. "Ball" & "Player". All collision detection is done in my "main" CPP file. This is a very basic and no doubt bad way of doing things. All the windows type stuff is handled by NeHe''s framework. What classes SHOULD I have and what should derive from what, etc etc? I''d appreciate some help! Cheers y''all - seb

Share this post


Link to post
Share on other sites
Advertisement
The classes you should have are what you need to make working with and/or maintaining the code easy for you. If it works well for you the way it is now, and the game runs fine, then it is not necessarily the ''wrong'' way of doing it.

Invader X
Invader''s Realm

Share this post


Link to post
Share on other sites
The ultra-OO way would be to specify an abstact base classes called something like IPhysics or ICollidable, which both the ball and player (player? you mean paddle? I''d expect a player object to have a paddle, a score, and a side of the board, etc...) objects would inherit.

Inside IPhysics you''d have methods to check the current position of the object and it''s bounding volume. Then maybe a static method to test if two objects intersect/collide.

Share this post


Link to post
Share on other sites

  • Advertisement