ACCOMODATES UP TO 3 PLAYERS BUT CAN BE EXPANDED TO ACCOMODATE MORE
USES NUMERAL KEYS 1,2,3 (NOT NUMERIC KEYPAD)
SHOWS WHICH PLAYER BUZZED IN FIRST, LOCKING OUT OTHER PLAYERS UNTIL RESET BY PRESSING SPACE BAR
CUSTOMIZABLE IN ALL SORTS OF WAYS — YOU CAN ADD SOUND EFFECTS AND SCORING
YOU WILL NEED BUTTONS WHICH SEND NUMERIC KEY CODES TO THE COMPUTER
https://www.compuphase.com/usbkey/usbbutton_en.htm
Code: Select all
;LOCKOUT.PB
;CREATED ON 12/2/2019 by chris319
;LOCKOUT PROGRAM FOR GAMES REQUIRING PLAYERS TO "BUZZ IN" SUCH AS JEOPARDY!
;ACCOMODATES UP TO 3 PLAYERS BUT CAN BE EXPANDED TO ACCOMODATE MORE
;USES NUMERAL KEYS 1,2,3 (NOT NUMERIC KEYPAD)
;SHOWS WHICH PLAYER BUZZED IN FIRST, LOCKING OUT OTHER PLAYERS UNTIL RESET BY PRESSING SPACE BAR
;CUSTOMIZABLE IN ALL SORTS OF WAYS — YOU CAN ADD SOUND EFFECTS AND SCORING
;YOU WILL NEED BUTTONS WHICH SEND NUMERIC KEY CODES TO THE COMPUTER
; https://www.compuphase.com/usbkey/usbbutton_en.htm
InitKeyboard()
LoadFont (1,"arial",24)
#H = 360: #W = 640
OpenWindow(1,0,0,#W,#H,"")
TextGadget(1, 50, 50, 400, 40,"",#PB_Text_Center):SetGadgetFont(1,FontID(1)):SetGadgetColor(1,#PB_Gadget_FrontColor, #White):SetGadgetColor(1,#PB_Gadget_BackColor, #Blue)
SetGadgetText(1,"Enabled")
TextGadget(2, 50, 100, 400, 40,"",#PB_Text_Center):SetGadgetFont(2,FontID(1)):SetGadgetColor(2,#PB_Gadget_FrontColor, #Black):SetGadgetColor(2,#PB_Gadget_BackColor, #Yellow)
AddKeyboardShortcut(1,#PB_Shortcut_1,#PB_Shortcut_1)
AddKeyboardShortcut(1,#PB_Shortcut_2,#PB_Shortcut_2)
AddKeyboardShortcut(1,#PB_Shortcut_3,#PB_Shortcut_3)
AddKeyboardShortcut(1,#PB_Shortcut_Space,#PB_Shortcut_Space)
Repeat:
event = WaitWindowEvent()
If event = #PB_Event_CloseWindow: CloseWindow(1): End :EndIf
If event = #PB_Event_Menu ;KEYBOARD INPUT
shortcut = EventMenu()
If shortcut = #PB_Shortcut_1 And locked = #False: locked = #True: SetGadgetText(2,"Player 1"): EndIf
If shortcut = #PB_Shortcut_2 And locked = #False: locked = #True: SetGadgetText(2,"Player 2"): EndIf
If shortcut = #PB_Shortcut_3 And locked = #False: locked = #True: SetGadgetText(2,"Player 3"): EndIf
If shortcut = #PB_Shortcut_Space: locked = #False: EndIf ;SPACE BAR UNLOCKS PLAYERS
If locked = #True:SetGadgetText(1,"Press space bar to reset")
Else: SetGadgetText(1,"Enabled"):SetGadgetText(2,""):EndIf
EndIf
ForEver