Skip to main content
GameDev.net gamedev.net
🔒 Locked

RTS object organization

Started by Hammer2k2 Apr 19, 2003 at 8:10 AM 2 replies 900+ views
Original Post
Hammer2k2
Hammer2k2
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
Alan Kemp
Alan Kemp
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
tellman
tellman
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
cairnswm
cairnswm
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.