To explain my idea, let us take an input manager for example. I would like to be able to store events and functions together in the following way:
class InputManager {
private:
map<int eventID, void(*function)()> eventActions
public:
void bind(int eventID, void(*function)());
void handleEvent();
};
so that I can write the actual game code in the form of a bunch of functions that I can bind to an event. Then all I have to do is call the handleEvent(), and it will detect events and call their corresponding function.
What I don't get is how I would go by and organize the code so that all functions I write has access to all the resources like TextureManager, SoundManager, EntityManager.
Is this possible to do?
Is it a good way of coding games?
Can I do it better differently?
thx for all the answers and sorry for a somewhat misleading title.
Edited by BosseBL, 13 June 2012 - 05:29 AM.






