TAILIEUCHUNG - microsoft visual basic game programming with directx phần 5

Nettrix: GDI + và Collision Detection Nếu bạn 2 - Netterpillars: Trí tuệ nhân tạo điều bạn muốn Chapterwere để thử nghiệm game này vào thời điểm này, và Sprites khám phá ra là bạn có thể lái máy bay của bạn ra khỏi Quản lý DirectX bước đầu tiên: Khái niệm cơ bản Direct3D và DirectX so với GDI + | Figure 4-20 Our plane flying over trouble waters If you were to test this game at this point one thing you d discover is that you can drive your plane off the screen. Although you can come back later it s not a good game practice. So we d better include some testing on our movement procedure to avoid this just after the line in which we set the PlayerMatrix variable inside theif command the m41 element represents the translation on the X axis If Then _ If Width - 1 Then Width - 1 the m42 element represents the translation on the Y axis If Then _ If Height - 1 Then Height - 1 We can now control the plane within the screen limits. Innext section we ll code the collision detection functions so the first version of our game will be almost fin ished. Fourth Draft Collision Detection The collision detection in our game will be fairly simple We ll use an algorithm that will provide approximate results to make the code simpler. Although it s not very accurate it ll suffice for fair game play. The basic idea here is to check the current player position convert it to x y coordinates of the Tiles array and then check the tile array element we are over to see if we are colliding. There ll be three types of collisions If we are over water we aren t colliding. If we are over a gas barrel we aren t colliding but we ll need to destroy the gas barrel tile fill our tank with some gas and create a new tile with water to replace the gas tile. If we are over a bridge a ship or a plane we are colliding. TheTestCollision method will return a Boolean indicating if we are colliding or not so the Render procedure will deal with the collision as appropriate. One last point before looking at .

TỪ KHÓA LIÊN QUAN
Đã 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.