3D 1P Game Design Best Practices?
I'm developing a game where one shoots at targets and would like some advice on how to pattern the overall architecture, specifically to do with collision detection and the interactions of those collisions.
For example, say I have two entities, A (the player) and B (the AI), and each can shoot at one another. Let us also suppose that A can shoot at B and either hit or miss, and B can shoot back at A and either hit or miss. If A misses, the shot simply disappears. If B misses, his shot hits a wall and causes a specific behavior (like "Boom!"). Finally, if A hits B, B explodes with a specific action. If B hits A, A explodes too, but differently than B.
With me so far?
Now... how can the game classes be structured so that each game actor can be placed into the game, interact with other actors, and all communicate together to know how to explode depending on how it was hit and by what?
Torin...
What kind of 3d environment are you using?
Have a look at [url= http://java.dnsalias.com]GAGE[/url], it has a fairly flexible and very efficient architecture for resolving collisions.
Abuse at 2007-7-5 22:00:59 >

I'm using Java 3D, and I already have the collision detection mechanism in place. For every item created in this universe, it has a collision detection class assigned to its top node (and thus, every node beneath). When it collides with something (or something collides with it), the collision detection class calls a callback in the collided node, informing it of what it was hit by.
That's where I run into the difficulty. I want to know if this is the appropriate way of dealing with collisions, or if it is more common practice to let the main game engine handle this sort of event.
If I leave it the way it is, each node would be responsible for determining what it was hit by and either blowing up, or partially disabling the sub-component (leg, arm, etc.) that was hit. No problem so far, but then upon being destroyed, the object must remove itself (or communicate to have itself removed), and I don't think it's appropriate for children to handle or delegate their own removal. I believe that responsibiliy should be handled by a rule engine or game logic controller of some sort. The other problem is, how do I communicate points, or a game over condition back to the game?
I think I should build a game logic core. I think I also need to pass this core reference to each node inserted into the game so that it has controlled, indirect access to all other components of the game. For example, why shouldn't an opponent be able to see the player and act more intelligently? Right now, the opponents blindly run around, shooting at random.
This is why I want to look at popular patterns. If I construct some sort of centralized game controller, the callbacks could be sent there. Upon the game controller realizing that node A destroyed one of the B Nodes, it could call each of the nodes with an appropriate action (blow up, disable part p, etc.), and could calculate points, game over conditions, whether any opponents were left and if it should proceed to the next level, etc.
Do you know of a Game Controller pattern?
Torin...
I'd have the object that controls the world control the world collisions. The object that adds explosions to the scene should be controlled by the world also. So have that main screen object traverse the pieces of the objects, and when one needs to be removed, it removes it, and makes the decision of what explosion to place.
sounds to me like a FiniteStateMachine can simple resolve the collision. Simply place different ouputs for different stimuli and obtain the output when a particular stimuli has been intercepted by either A or B.
If you have Game Programming Gems 1 which you *should* have. then its in there with the AI bit.
Hope that helps, Digiwired
Thanks Guys,
Sometimes, it helps to whiteboard the thought process...
I worked out the details and determined that I needed centralized management structure as the hub of communications for game play altering events. I called it the GameController
The GameController is responsible for bringing objects into and out of the universe. It is also responsible for tallying scores, re-inserting players until they "run out of men", and accepting projectiles from each of the game players. (i.e. When a player fires, he must ask the GameController to insert the projectile on his behalf.)
The players themselves are responsible for their own movement once in the arena, for detecting collisions, and altering their appearance. For example, when an opponent is hit by a projectile, it can determine whether to take damage or blow up entirely, and either display the new damage, or show an explosion. In each case, that node is responsible for telling the GameController its new state. The GameController can then add points to the player's score, or remove the destroyed opponent entirely.
I'll check out the "Game Programming Gems" series. Thanks for the tip.
Torin...
