O'Reilly logo

Android Game Programming by Example by John Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introducing Bob

Here, we can add the meat to the bones of your Player class. However, this section won't be the last time we revisit the Player class. Now, we will add the necessary functionality to allow Bob to move. Immediately after we have done this, we will add the code to allow the player to use the forthcoming collision detection code and the Animation class.

First of all, we need to add some members to the Player class. The Player class will need to know how fast it can move, when the player is pressing the left or right controls, and if it is falling or jumping. In addition, the Player class needs to know how long it has been jumping and how long it should jump for.

The next block of code provides variables for us to monitor all these things. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required