tailieunhanh - Microsoft XNA Game Studio Creator’s Guide- P19

Microsoft XNA Game Studio Creator’s Guide- P19:The release of the XNA platform and specifically the ability for anyone to write Xbox 360 console games was truly a major progression in the game-programming world. Before XNA, it was simply too complicated and costly for a student, software hobbyist, or independent game developer to gain access to a decent development kit for a major console platform. | 18 MICROSOFT X N A GAME STUDIO CREATOR S GUIDE node. Once you have done this you can load your model files from the LoadContent methods alienOModel Model Models alienO alienOMatrix new Matrix alienOMatrix alienlModel Model Models alien1 alienlMatrix new Matrix alienlMatrix To orient the aliens according to their direction on the Y axis the YDirection method is required in the game class float YDirection Vector3 view Vector3 position Vector3 forward view - position return float double double To transform the alien models when drawing and updating them add these methods to the game class Matrix Scale const float SCALAR return SCALAR SCALAR SCALAR Matrix TransformAliens bool host bool controlledLocally Vector3 position Vector3 view 1 declare matrices Matrix yRotation translateOffset rotateOffset translation 2 initialize matrices yRotation float offsetAngle YDirection view position rotateOffset offsetAngle const float YOFFSET const float Z_OFFSET translateOffset YOFFSET Z_OFFSET translation new Vector3 3 build cumulative world matrix using . sequence identity scale rotate orbit translate rotate translate return yRotation translateOffset rotateOffset translation chapter 2 9 To update the local position and view data each frame add Update-GameNetwork to your game class. updates the view and position coordinates according to the changes of the locally controlled aliens. Once the local view and position data is calculated these values are passed to the network class for distribution across the network public void UpdateGameNetwork if null update menu if no game yet UpdateGameStart .