250 likes | 628 Views
User Interface Dr. Scott Schaefer User Interface Make it simple/easy to do common tasks Don’t obscure the FOV Simpler is typically better Consistency is important! Diablo Warcraft 3 World of Warcraft Quake 3 Quake 4 Madden ‘09 Game Control Must consider single/multi-player aspect
E N D
User Interface Dr. Scott Schaefer
User Interface • Make it simple/easy to do common tasks • Don’t obscure the FOV • Simpler is typically better • Consistency is important!
Game Control • Must consider single/multi-player aspect • Single player? • Networked multi-player? • Multi-player same machine? • Platform limitations
Game Control: Keyboard/Mouse • Connected to every PC but lacking on most other platforms • Fine for single player or multi-player networked • Lots of buttons!
Game Control: Joystick • Found on most consoles • Can also be connect to PC via USB • Win NT supports 2 joysticks • Later versions support 16 joysticks
Joystick Programming with Win32 #include<windows.h> #include<mmsystem.h> intjoyGetNumDevs ( void) • Returns: number of joysticks supported by driver (not number connected to machine)
Joystick Programming with Win32 MMResult joyGetDevCaps ( int id, JOYCAPS*cap, int size ) • id: id of the joystick being tested (-1 through 15) • cap: pointer to a JOYCAP structure • size: size of structure pointed to by cap • Returns: JOYERR_NOERROR if no error
Joystick Programming with Win32 • typedefstruct { short wMid; short wPid; char szPname[MAXPNAMELEN]; unsigned int wXmin, wXmax, wYmin, wYmax, wZmin, wZmax; unsigned int wNumButtons; unsigned int wPeriodMin, wPeriodMax; unsigned int wRmin, wRmax, wUmin, wUmax, wVmin, wVmax; unsigned int wCaps; unsigned int wMaxAxes; unsigned int wNumAxes; unsigned int wMaxButtons; char szRegKey[MAXPNAMELEN]; char szOEMVxD[MAX_JOYSTICKOEMVXDNAME]; } JOYCAPS;
Joystick Programming with Win32 • typedefstruct { short wMid; short wPid; char szPname[MAXPNAMELEN]; unsigned int wXmin, wXmax, wYmin, wYmax, wZmin, wZmax; unsigned int wNumButtons; unsigned int wPeriodMin, wPeriodMax; unsigned int wRmin, wRmax, wUmin, wUmax, wVmin, wVmax; unsigned int wCaps; unsigned int wMaxAxes; unsigned int wNumAxes; unsigned int wMaxButtons; char szRegKey[MAXPNAMELEN]; char szOEMVxD[MAX_JOYSTICKOEMVXDNAME]; } JOYCAPS; number of buttons
Joystick Programming with Win32 • typedefstruct { short wMid; short wPid; char szPname[MAXPNAMELEN]; unsigned int wXmin, wXmax, wYmin, wYmax, wZmin, wZmax; unsigned int wNumButtons; unsigned int wPeriodMin, wPeriodMax; unsigned int wRmin, wRmax, wUmin, wUmax, wVmin, wVmax; unsigned int wCaps; unsigned int wMaxAxes; unsigned int wNumAxes; unsigned int wMaxButtons; char szRegKey[MAXPNAMELEN]; char szOEMVxD[MAX_JOYSTICKOEMVXDNAME]; } JOYCAPS; min/max bounds for “hat” controllers
Joystick Programming with Win32 MMResult joyGetPosEx ( int id, JOYINFOEX*info) • id: id of the joystick being tested (-1 through 15) • info: pointer to a JOYINFOEX structure • Returns: JOYERR_NOERROR if no error JOYERR_UNPLUGGED if joystick not connected
Joystick Programming with Win32 • typedefstruct { int dwSize; int dwFlags; int dwXpos, dwYpos, dwZpos; int dwRpos, dwUpos, dwVpos; int dwButtons; int dwButtonNumber; int dwPOV; int dwReserved1; int dwReserved2; } JOYINFOEX;
Joystick Programming with Win32 • typedefstruct { int dwSize; int dwFlags; int dwXpos, dwYpos, dwZpos; int dwRpos, dwUpos, dwVpos; int dwButtons; int dwButtonNumber; int dwPOV; int dwReserved1; int dwReserved2; } JOYINFOEX; MUST be sizeof( JOYINFOEX)
Joystick Programming with Win32 • typedefstruct { int dwSize; int dwFlags; int dwXpos, dwYpos, dwZpos; int dwRpos, dwUpos, dwVpos; int dwButtons; int dwButtonNumber; int dwPOV; int dwReserved1; int dwReserved2; } JOYINFOEX; SHOULD be JOY_RETURNALL
Joystick Programming with Win32 • typedefstruct { int dwSize; int dwFlags; int dwXpos, dwYpos, dwZpos; int dwRpos, dwUpos, dwVpos; int dwButtons; int dwButtonNumber; int dwPOV; int dwReserved1; int dwReserved2; } JOYINFOEX; position of “hat” controllers
Joystick Programming with Win32 • typedefstruct { int dwSize; int dwFlags; int dwXpos, dwYpos, dwZpos; int dwRpos, dwUpos, dwVpos; int dwButtons; int dwButtonNumber; int dwPOV; int dwReserved1; int dwReserved2; } JOYINFOEX; bit array with bit set if button currently pressed
Joystick Programming with Win32 • typedefstruct { int dwSize; int dwFlags; int dwXpos, dwYpos, dwZpos; int dwRpos, dwUpos, dwVpos; int dwButtons; int dwButtonNumber; int dwPOV; int dwReserved1; int dwReserved2; } JOYINFOEX; number of buttons pressed
Joystick Programming with Win32 • typedefstruct { int dwSize; int dwFlags; int dwXpos, dwYpos, dwZpos; int dwRpos, dwUpos, dwVpos; int dwButtons; int dwButtonNumber; int dwPOV; int dwReserved1; int dwReserved2; } JOYINFOEX; angle of POV controller