Hi all, I've been a long time lurker for a few years after a long break from the site.
I'm still a beginner, but am really pushing to get a few games under my belt.
Anyway, I've set up a basic game design like this:
Game class Singleton
Game State Class (for playing/paused etc)
- handle input
Game Object Class
- list of sprites for animation
- virtual handle input (calls state->handle_input)
- virtual update (calls state->update)
- virtual draw (calls state->draw)
- Monster Class (derived from GameObject)
- Player Class (derived from GameObject)
- virtual handle_input
- virtual update
- virtual draw
MonsterState Class (derived from State)
PlayerState Class (derived from State)
Object Manager Class
- manages a list of game objects of a type eg ObjectManager<Monster> monster_manager;
- calling monster_manager.update() runs the update command on all the monster objects etc
Okay, so now that's out of the way, my problem is how do I get my objects talking to the manager? I want my player object for example to be able to tell the manager to create bullet objects.
But it seems the way I've designed it all only allows for messages to be sent downwards, not upwards. I tried including the calling objectmanager on each update call, but because the objectmanager is templated it didn't work.
I thought of creating a global messaging system, where a list of message objects is kept and every loop they are executed, but that's just moving the problem around, not really changing the structure (ie the message class would need access to the ObjectManager)
Am I going about this the wrong way?
Are there any good examples of basic games (but not Pong) that allow for expansion? Maybe something like object oriented space invaders?