Jump to content
  • Advertisement
Sign in to follow this  
Kobaltic

Declaring a map object

This topic is 4297 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 am trying to declare an object (ball) so that either team can pick up the ball. I am modding existing code and I am stuck. If you look at the code below you will see that there are 2 balls one for each team. I want there to be only 1 ball that both teams use. I do not know how to declare it since it is declared by which team the ball is for. Any help would be great. If more code is needed let me know here is the header info:
class RB_RBTeam : public RB_Team
{
public:
   RB_RBTeam();
   void onBeginRound();
   void setDroppedController(RB_ItemControllerAPI & icapi);
   bool updateTrackedballs();
   void releaseControllers();
   void makeballAvailable();
   bool availableball();
   RB_MenuPageAPI& getballIndicatorPage();
   
   std::string             ball_name;
   std::string             enemy_ball_name;
   std::string             endzone_name;
   std::string             enemy_endzone_name;
   
   bool                    track_dropped_controller;
   RB_ItemControllerAPI  ball_controller;
   RB_ItemControllerAPI  dropped_ball_controller;
	
};
here is the .cpp file info:
RB_RBMode::RB_RBMode()
{
   shortID = "RB";
   mode_index=MODE_RB;
   // create the two teams
   _teams[0] = new RB_RBTeam;
   _teams[1] = new RB_RBTeam;
   getTeam(1)->team_name=TEAM_NAMES[0];     // Definable?
   getTeam(2)->team_name=TEAM_NAMES[1];
   getTeam(1)->team=1;
   getTeam(2)->team=2;
   getTeam(1)->ball_name=("ball1");
   getTeam(1)->enemy_ball_name=("ball2");
   getTeam(2)->ball_name=("ball2");
   getTeam(2)->enemy_ball_name=("ball1");


    onInterfaceLoaded();

Share this post


Link to post
Share on other sites
Advertisement
Another option is to have a static ball object. This way there is only one instance of object when it's referenced by other objects.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!