Book Image

Creative Greenfoot: RAW

By : Michael Haungs
Book Image

Creative Greenfoot: RAW

By: Michael Haungs

Overview of this book

Table of Contents (17 chapters)
Creative Greenfoot
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The Greenfoot Gamepad API


The Greenfoot Gamepad API supports all of the controls shown in Figure 1 except that there are only two auxiliary buttons at the top (colored orange). First, we will discuss the API at a conceptual level and then look at the specific classes that implement the API.

Overview

In theory, receiving user input from a gamepad is a lot like receiving input from the keyboard. We are going to poll the buttons and analog sticks on the gamepad to see whether they are presently being pressed. The analog sticks are a bit more complicated as they have more states than being pressed or not. For them, you need to know both the direction they are being pushed in and the strength of the push.

With gamepads, you might have multiple gamepads connected to your computer, so the API also provides methods to access all of the gamepads and connect to only the ones you specify.

As we saw in the gamepad template scenario, the Gamepad API is implemented in two classes. The first is the GamePad...