Okay so i'm working on a small game just for learning purposes.
Since the game is multiplayer, I have many things to manage.
For example, I have a few different enums set up
For the current screen you're looking at (Ex. Into Screen/Login Screen/AboutScreen/etc) I have an enum inside of my game class (Note: This is only part of the code, not trying to overcomplicate things.)
1 2 3 4 5 6 7 8 9 10 11 12 13
|
class Game
{
public:
enum Screens {
GS_MainScreen,
GS_About,
GS_Online,
GS_HowToPlay,
GS_ServerScreen,
GS_CreateGame,
GS_LoadingGame
};
}
|
For the thread running on the client side, I also have to have enums to store the indexes for the Current Task that the client thread is performing as well as have an enum to store the Packet Type of the packet being received/sent.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
namespace PacketType
{
enum {
CHATMESSAGE,
DISCONNECTCLIENT
};
}
namespace Task
{
enum {
RECEIVINGPACKETTYPE
};
}
|
So for example, if I want to set my Task in my Client Thread to be the "Receiving Packet Type" task, I can do
MyTask = Task::RECEIVINGPACKETTYPE;
And also, if I am checking if a packet's type is a chat message, I could do
1 2 3 4
|
if (MyPacketType == PacketType::CHATMESSAGE)
{
//Do Stuff;
}
|
So here is what i'm getting to.
I realize that I can use namespaces outside of a class to organize certain things such as enums, and inside of a class I can organize enums by the main enum name, but here is where i'm lost.
Let's say I have 30+ methods inside the game class. I know I can not make a namespace inside of the game class, but is there any way I can organize my methods inside of my game class other than creating more classes?
So if I have
1 2 3 4 5 6 7 8 9 10 11 12
|
class Game
{
public:
void DrawFunc1();
void DrawFunc2();
void DrawFunc3();
void DrawFunc4();
void SoundFunc1();
void SoundFunc2();
void SoundFunc3();
//etc...
}
|
Is there any way I could organize it so that I could have something like in order to call DrawFunc1 I could do
1 2 3
|
Game MyGame;
MyGame::DrawFunctions::DrawFunc1();
MyGame::SoundFunctions::SoundFunc1();
|
^ I realize it wouldn't look exactly like this, but i'm hoping you understand what i'm trying to get at. Is there any way I can organize my methods inside of a class without creating classes inside of that class?
Thanks for reading through all of my rambling. Hope this isn't too confusing.