tailieunhanh - Microsoft XNA Game Studio Creator’s Guide- P16
Microsoft XNA Game Studio Creator’s Guide- P16: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. | 428 MICROSOFT X N A GAME STUDIO CREATOR S GUIDE These next instructions belong inside LoadContent to load the spaceship model shipModel Model Models alien1 shipMatrix new Matrix shipMatrix UpdateShipPosition is used in the game class to not only move the ship on X and Z but also Y to match the height of the terrain below void UpdateShipPosition GameTime gameTime const float HOVER_DISTANCE ship s X Y Z position without hover distance above the ground - HOVER_DISTANCE reverse direction if right boundary exceeded if -BOUNDARY positiveDirection false shipVelocity positiveDirection true reverse direction if left boundary exceeded else if BOUNDARY positiveDirection true shipVelocity positiveDirection false increment position by time scale so speed is same on all systems float time float time time CellHeight shipPosition HOVER_DISTANCE To update the ship height each frame trigger the ship update at the end of the Up-date method UpdateShipPosition gameTime When drawing objects that use the terrain you need to do more than just update their positions and directions about the Y axis. You also need to update their orientation relative to the slope of the terrain where they are located. This next section of code allows you to do this. CHAPTER 25 When you re drawing the spaceship the ship s Up vector is calculated using a weighted average of leading and trailing normal vectors in the ship s path see Figure 25-5 . This weighted average prevents a jerking motion caused as the ship s Up vector changes from one cell to the next. If you want to make it look as if you don t have any shock absorption you can just use the normal vector for the current cell only. Whether you are calculating weighted or normal vectors a
đang nạp các trang xem trước