I had some troubles in my game-architecture. The question was - how to make Enemy objects, Bullet objects and Player object interact one with another without implementing tons of singletones?
I decided to look up for decision of this problem in SFML development book. I read 7 chapters of this book, paid attention to every line of it, but i still can't find solution: how to make enemies objects know where player is located to move forward to it? Cuz i was a bit disappointed, when i realized that flights in that example game were moving just by patterns and made an illusion of AI.
Should i make methods like
void Enemy::move(Player& player, float dt);
? I mean, using references to other classes. Doesn't it ruin OO-style?
Or should I just use those singletones?
Sorry for such questions, but game-architecture brings lots of troubles for people without experience in it :-\
I read 7 chapters of this book, paid attention to every line of it, but i still can't find solution: how to make enemies objects know where player is located to move forward to it?
You have looked for the wrong things. We have implemented interaction between a variety of entity combinations for collisions, and between guided missiles and enemies for targeting. It should be possible to extend that to enemies vs player.
Should i make methods like
void Enemy::move(Player& player, float dt);
? I mean, using references to other classes. Doesn't it ruin OO-style?
That's one option, then you would implement the AI logic directly in the Enemy class. I don't know what this "OO style" is, seems like a myth to me. Possibly spread by Java developers ;)
Alternatively, for better separation of concerns, a third instance -- an AI controller -- is responsible of that task. It knows about the player and gives instructions to the enemies. The enemies provide an interface to accept such instructions, but they don't decide on their own.
Or should I just use those singletones?
No, avoid singletons and global variables. See also some of my tips here (http://en.sfml-dev.org/forums/index.php?topic=13977.msg97950#msg97950).