RTS object organization

Started by
2 comments, last by Hammer2k2 20 years, 12 months ago
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
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
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
Hey.

Singleton is nice but I think you can also do it with queues.
Here''s and article on Flicode - it''s pretty straigt foward.

Managing Unit Actions



... no magic ... just coding
... no magic ... just coding<br/>Blogger
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.

This topic is closed to new replies.

Advertisement