Game Development Reference
In-Depth Information
This delegate calls VOnRestore() on the scene node to get it into a renderable state
and adds it as a child to the scene.
When an actor is destroyed, the EvtData_Destroy_Actor event is sent. The scene
must also catch this event to properly remove the child:
void Scene::DestroyActorDelegate(IEventDataPtr pEventData)
{
shared_ptr<EvtData_Destroy_Actor> pCastEventData =
static_pointer_cast<EvtData_Destroy_Actor>(pEventData);
RemoveChild(pCastEventData->GetId());
}
The Game View for a Human Player
The game view ' s job is to present the game, accept input, and translate that input
into commands for the game logic. There are three kinds of views that can attach
to Teapot Wars: a view for a local human player, a view for an AI player, and a
view that represents a player on a remote machine. The last one, NetworkGame-
View , was presented at the end of Chapter 19.
The view for the human player is responsible for the 3D graphics, audio, and user
interface of the game. There are two classes that make this system work. The first is
TeapotWarsHumanView , which inherits from the HumanView class presented in
Chapter 10,
This class hooks into the Windows appli-
cation layer message pump for user interface processing and organizes user interface
objects, like buttons and text strings on top of a 3D scene background. The second
class is TeapotController , which reads input from the keyboard and mouse and
translates input into commands that are sent to the game logic.
The code for the TeapotWarsHumanView is quite a bit longer. It has a lot of work
to do, keeping track of the 3D scene, audio, graphical object creation, and presenting
the user interface.
User Interface Programming.
class TeapotWarsHumanView : public HumanView
{
protected:
bool m_bShowUI; // If true, it renders the UI control text
std::wstring m_gameplayText; // text being displayed at the top-center
shared_ptr<TeapotController> m_pTeapotController;
shared_ptr<MovementController> m_pFreeCameraController;
shared_ptr<SceneNode> m_pTeapot;
shared_ptr<StandardHUD> m_StandardHUD;
 
 
Search WWH ::




Custom Search