TAILIEUCHUNG - Microsoft XNA Game Studio Creator’s Guide- P8

Microsoft XNA Game Studio Creator’s Guide- P8: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. | 188 MICROSOFT XNA GAME STUDIO CREATOR S GUIDE SineCycle traces a floating-point value through a sine wave s cycle over time. The function is only executed once per frame but is used to update each Y value for all vertices in the grid. Add this function to your game class float SineCycle GameTime gameTime less than full cycle of sine wave retrieves between 0 and 1. full cycle for sine wave is 2 PI. if cycleincrement 1 cycleIncrement float adjust when sine wave cycle complete else cycleincrement cycleincrement - 1 return cycleIncrement As discussed SineCycle is called only once per frame to trace a value on the sine wave over time. The point on the sine wave that is returned is added to the V coordinate for each point in the grid. This sum is used for setting the Y value of each point in the grid. The result is a set of oscillating Y values that follow the sine wave as it rises and falls over time. SetWaterHeight receives the sum of the texture s V coordinate plus the point in the sine wave over time. This sine wave equation returns a Y value for the coordinate that corresponds with the V coordinate Height Amplitude sin WaveCountPerCycle PointInCycle 2n Add the SetWaterHeight method to the game class float SetWaterHeight float cycleTime const float FREQUENCY wave count per cycle const float AMPLITUDE wave height generates height based on V coord and sine equation return AMPLITUDE float FREQUENCY cycleTime float - CHAPTER 12 1 89 The X Y Z information is the same for both the stationary image layer and the moving image layer. Since the stationary layer is drawn first the Y value that changes with the sine wave over time can be set for this layer and the changes will apply to both image layers. Adding this code to reset the X Y and Z coordinates inside the nested for-loop for UpdateMovingSurface will create a dynamically changing Y value that simulates the wave for both layers .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.