TAILIEUCHUNG - Programming Linux Games phần 4

PIP tutorial là trang chuyên cung cấp các bài viết hướng dẫn thực hành về các lĩnh vực như: lập trình, đồ họa, mạng, bảo mật. Với mong muốn tạo ra một môi trường học tập tốt nhất cho các học viên từ mọi miền, PIP luôn luôn lắng nghe các ý kiến đóng góp từ phía các bạn. | 114 CHAPTER 4 printf Press Q to quit. n Start the event loop. Keep reading events until there is an error or the user presses a mouse button. while SDL_WaitEvent event 0 SDL_keysym keysym SDL_WaitEvent has filled in our event structure with the next event. We check its type field to find out what happened. switch case SDL_KEYDOWN printf Key pressed. keysym printf SDL keysym is i. printf s SDL_GetKeyName Report the left shift modifier. if KMOD_LSHIFT printf Left Shift is down. n else printf Left Shift is up. n Did the user press Q if SDLK_q printf Q pressed exiting. n exit 0 break case SDL_KEYUP printf Key released. printf SDL keysym is i. printf s SDL_GetKeyName if KMOD_LSHIFT printf Left Shift is down. n else printf Left Shift is up. n MASTERING SDL 115 break case SDL_QUIT printf Quit event. Bye. n exit 0 return 0 It is important to note that a keystroke generates only one event regardless of how long a key is held down. Games generally use the keyboard as a set of control buttons not as character input devices and so the normal key repeat feature is most often of no use to them. However you can enable key repeat with the SDL_EnableKeyRepeat function. This might be useful for implementing text fields in dialog boxes for instance. Function SDL_EnableKeyRepeat delay rate Synopsis Enables key repeating. This is usually disabled for games but it has its uses and is almost always enabled for normal typing. Parameters delay Milliseconds to wait after a key is initially pressed before repeating its event. A delay of 0 disables key repeating. A typical value is somewhere in the range of 250-500. rate Milliseconds between repeats. A typical value is 30. As with the mouse it is possible to read the keyboard s state directly bypassing the event interface. There is no function for directly obtaining the state of an individual key but a program can .

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.