In this course concepts and requirements of the video game development will be taught. Students will get familiar to the fundamentals of the game industry and finally put all the learned stuff together to work on a small game project.
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
09. User Input
1. Video Game Development: User InputA. Babadi 1 of 20
In The Name Of God
Video Game Development
Amin Babadi
Department of Electrical and Computer Engineering
Isfahan University of Technology
Spring 2015
User Input
2. Video Game Development: User InputA. Babadi 2 of 20
Outline
The keyboard
Mouse
Joysticks
Hardware abstraction
Force feedback
3. Video Game Development: User InputA. Babadi 3 of 20
User Input
A smooth user interaction model is key to any good game.
Sadly, there will be few general rules.
User interaction takes place at a relatively low abstraction
level, and implementations tend to be quite hardware
dependent.
4. Video Game Development: User InputA. Babadi 4 of 20
The Keyboard
Keyboards are the main input device for PC-based games, but
are also available for mobile phones, some consoles, and palm
devices.
The most widely available input device!
Unfortunately, such a popular input device is not very well
suited for games.
5. Video Game Development: User InputA. Babadi 5 of 20
The Keyboard
For gaming purposes, two types of routines for reading
keyboards are relevant.
1. Synchronous routines
2. Asynchronous routines
6. Video Game Development: User InputA. Babadi 6 of 20
1. Synchronous Routines
Synchronous routines wait until a key is pressed and then
report it to the application.
Synchronous read modes are used to type information, such
as the character name.
But they are not very well suited for real gameplay (why?).
7. Video Game Development: User InputA. Babadi 7 of 20
2. Asynchronous Routines
Asynchronous routines return immediately after being called,
and give the application information about which keys were
pressed, if any.
Asynchronous controllers are the way to go!
They provide fast tests to check the keyboard state efficiently.
8. Video Game Development: User InputA. Babadi 8 of 20
2. Asynchronous Routines
Asynchronous routines can also belong to two different
families.
o Some of them are designed to test the state of individual keys (how?).
o Others retrieve the whole keyboard state in a single call.
What are pros/cons of these 2 sub-types?
Which sub-type is generally more efficient? Why?
9. Video Game Development: User InputA. Babadi 9 of 20
Mouse
Mice are especially popular in PC games, but game consoles
do not usually support them.
Unlike a keyboard or joystick, a mouse not only generates
button or key presses, but 2D positions as well.
The operation of the mouse can be divided into transmitting
positional information and sending button press and release
messages.
10. Video Game Development: User InputA. Babadi 10 of 20
Mouselook
A popular use of the mouse is to implement the classic
mouselook used in many first-person shooters.
All we have to do is use the keys to change our position, and
use the mouse to reorient our viewpoint.
Killzone 3
11. Video Game Development: User InputA. Babadi 11 of 20
Joysticks
The joystick was introduced in the 1970s as a way to
represent positional data easily.
The first models were restricted to binary tests.
Today, all joysticks map the sticks' inclination to a continuous
range of values, so we can control our characters precisely.
Controlling a joystick is slightly more complex than working
with a keyboard or a mouse (why?).
12. Video Game Development: User InputA. Babadi 12 of 20
Response Curves
For example, imagine a game like Mario, where there is no
speed control: Mario is simply running left, running right, or
standing still.
Assume that the analog output is in the range −100,100 .
So how do we implement that using an analog controller?
We need to define a transfer function.
13. Video Game Development: User InputA. Babadi 13 of 20
Response Curves
Response curve without (left) and with (right) a dead zone.
14. Video Game Development: User InputA. Babadi 14 of 20
Response Curves
Types of response curves.
15. Video Game Development: User InputA. Babadi 15 of 20
Hardware Abstraction
Games that run on platforms that support a variety of input
controllers offer the richest gaming experience.
16. Video Game Development: User InputA. Babadi 16 of 20
Hardware Abstraction
There are two paths a developer might follow when coding for
such a platform:
o Some games will choose to use one (and only one) of the existing
controllers.
o Some other games will let the user choose the input method he or
she wants to employ.
Hardware abstraction means coding your game with a
"virtual" controller in mind, so any controller that conforms to
that abstract profile can be fitted into the code with zero
impact on the game engine.
17. Video Game Development: User InputA. Babadi 17 of 20
Hardware Abstraction
A possible class structure to implement device abstraction.
18. Video Game Development: User InputA. Babadi 18 of 20
Force Feedback
Many input controllers come with some sort of force feedback
these days.
Force feedback hardware simulates vibration and other force-
based effects by incorporating one or more motors that can
be configured via programming.
Sadly, these techniques are largely platform dependent.
19. Video Game Development: User InputA. Babadi 19 of 20
Force Feedback
Microsoft's Force Editor, built into the DirectX SDK.
20. Video Game Development: User InputA. Babadi 20 of 20
References
Sanchez-Crespo’s textbook,
Wikipedia, and
Some other sources on the Internet.