09. user input

20
Video Game Development: User Input A. 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

Upload: amin-babadi

Post on 18-Aug-2015

201 views

Category:

Engineering


5 download

TRANSCRIPT

Video Game Development: User Input A. 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

Video Game Development: User Input A. Babadi 2 of 20

Outline

The keyboard

Mouse

Joysticks

Hardware abstraction

Force feedback

Video Game Development: User Input A. 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.

Video Game Development: User Input A. 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.

Video Game Development: User Input A. Babadi 5 of 20

The Keyboard

For gaming purposes, two types of routines for reading keyboards are relevant. 1. Synchronous routines

2. Asynchronous routines

Video Game Development: User Input A. 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?).

Video Game Development: User Input A. 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.

Video Game Development: User Input A. 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?

Video Game Development: User Input A. 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.

Video Game Development: User Input A. 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

Video Game Development: User Input A. 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?).

Video Game Development: User Input A. 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.

Video Game Development: User Input A. Babadi 13 of 20

Response Curves

Response curve without (left) and with (right) a dead zone.

Video Game Development: User Input A. Babadi 14 of 20

Response Curves

Types of response curves.

Video Game Development: User Input A. Babadi 15 of 20

Hardware Abstraction

Games that run on platforms that support a variety of input controllers offer the richest gaming experience.

Video Game Development: User Input A. 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.

Video Game Development: User Input A. Babadi 17 of 20

Hardware Abstraction

A possible class structure to implement device abstraction.

Video Game Development: User Input A. 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.

Video Game Development: User Input A. Babadi 19 of 20

Force Feedback

Microsoft's Force Editor, built into the DirectX SDK.

Video Game Development: User Input A. Babadi 20 of 20

References

Sanchez-Crespo’s textbook,

Wikipedia, and

Some other sources on the Internet.