TAILIEUCHUNG - microsoft visual basic game programming for teens phần 7

bây giờ cuối cùng thông qua kinh nghiệm. Chỉ cần cố gắng thử nghiệm với các giá trị khác nhau hex trong chương trình SpriteTest để xem kết quả. Đó là nơi mà khoa học trong khoa học máy tôi mờ sprite để sử dụng tốt trong Chương 18, "Tham gia Trong chiến đấu với NPC", | 220 Chapter 11 Core Technique User Input Using DirectInput to Program a Joystick DirectInput dramatically simplifies joystick programming making it relatively easy to support a wide variety of joysticks with a single code base. The key to programming a joystick with DirectInput lies with two objects called DirectInputDevice8 and DirectlnputEnum-Devices8 as well as a structure called DIDEVCAPS. These three components provide the functionality to write a joystick handler Dim diDev As DirectInputDevice8 Dim diDevEnum As DirectInputEnumDevices8 Dim joyCaps As DIDEVCAPS Reading the List of Game Controllers The first thing you need to do is retrieve a list of available game controllers that are attached to the computer with a DirectInput function called GetDIDevices enumerate the game controllers Set diDevEnum DI8DEVCLASS_GAMECTRL _ DIEDFL_ATTACHEDONLY You can then use the diDevEnum variable to see if a joystick is available If 0 Then MsgBox No joystick could be found End If Creating the Joystick Device Object Once you have determined that a joystick is available the next step is to create the joystick object which is a DirectInputDevice8 object. While DirectInput supports multiple joysticks I show you how to work with the primary joystick attached to the computer because that is all you are likely to need. Here is the code to create the joystick object create the joystick object Set diDev 1 .GetGuidInstance DIFORMAT_JOYSTICK DISCL_BACKGROUND Or _ DISCL_NONEXCLUSIVE The Callback Procedure The next step to writing a joystick handler is to set up the event handler and the callback procedure. The event handler is actually returned by the primary DirectX object rather than the DirectInput object. Any VB program that needs to provide joystick support Programming the Joystick 221 through DirectInput must implement the DirectX event object at the top

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