Communicating between classes
I am pretty familiar with programming but I have more of a logic question.
If you have two enemy classes such as a zombie and a rabiddog that you create with in your program and want them to fight each other how would you handle communication between the two classes?
For example, would you use a handler that ran the combat between the two or is there a way to have just those two classes initiate combat (i.e. functions within zombie allow it to attack rabiddog on it's own). Like if they are randomly wandering around and you want to have one sense how close it is to the other so it attacks. Is there a way to program that into it's functionality or do you have to use an outside handler?
I'm thinking of having each room that I have in my game actually have a function that keeps up with room combat between anything that is fighting inside the room. I'm not sure though I wanted to get advice from anyone more seasoned at game programming than me.
|