Jump to content
  • Advertisement

Archived

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

Hammer2k2

RTS object organization

This topic is 5630 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

Hi! If I create an RTS. I have certain objects such as the pathfinder object which needs at its creation a pointer to a map object that you create beforehand. I have units too which want access to the pathfinder and at the same time the map. How would I organize the data in C++? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
Personally I would make the map class a singleton, then any other class can access it without having to pass pointers around.

A google search for "singleton design pattern" turns up quite a few links if you are not familiar with singletons.

Alan

Share this post


Link to post
Share on other sites
I have implemented the map as the controlling object of the game. Each unit or item on the map needs to register its existence with the Map. When the map draws itself it also tells each object in the view plane to draw itself.

Pathfinding is a funtion of the map. If an object is told to go from here to there it will ask the map to find the relevant path and will then follow the path.

Everything in the game that is map related is registered with the map, everything to do with the UI is not.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!