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

Microsoft XNA Game Studio Creator’s Guide- P3: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. | 38 MICROSOFT XNA GAME STUDIO CREATOR S GUIDE This might sound strange however it does make sense if you consider that changing the sprite s direction on X and Y requires a rotation about the Z axis. To get the versatility we need for implementing collision detection this chapter introduces the Z rotation matrix and the translation matrix. Z Rotation Matrix The Z rotation matrix is generated using the CreateRotationZ method. CreateRotationZ receives an angle in radians as a parameter and uses it to generate a matrix that will rotate sets of vertices around the Z axis Matrix rotationZ float radians Translation Matrix 2D translations are lateral movements on X and Y. The translation matrix is created using the CreateTranslation method. The CreateTranslation method receives three floating point values to set the lateral movement on X and Y. The last parameter Z is set to for 2D since the drawing is done in two dimensions float x float y float Z Building the Cumulative Transformation Cumulative transformation matrices for transforming a set of vertices are calculated by multiplying each individual transformation matrix with the others in this series. Here is an example of a cumulative matrix being generated by multiplying the translation matrix and rotation matrix together Matrix cumulativeTransform X Y Z radians The Intersects Method After your rectangle corners are transformed the Intersects method determines if one rectangle overlaps another. bool Rectangle Rectangle rectangle1 CHAPTER 4 FIGURE 4-3 2D Games False bounding rectangle collision There are problems with this method. Figure 4-3 shows a situation where a collision is detected but there actually is no collision. Another more accurate routine is required to check for collisions but you should still use rectangle collision checking to determine if it is even worth executing a more accurate

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.