Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Android Game Programming By Example
  • Table Of Contents Toc
Android Game Programming By Example

Android Game Programming By Example

By : John Horton
4.4 (9)
close
close
Android Game Programming By Example

Android Game Programming By Example

4.4 (9)
By: John Horton

Overview of this book

The book is best suited for existing Android or Java programmers who want to adapt their skills to make exciting Android games. The book is also for determined readers who might have no Android, game programming or even Java experience, but a reasonable understanding of object oriented programming knowledge is assumed.
Table of Contents (13 chapters)
close
close
7
7. Platformer – Guns, Life, Money, and the Enemy
12
Index

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. We will very soon see, how we use them to make Bob do what we want.

Now, we know what the variables are for. We can add this code right after the class declaration as shown:

public class Player extends GameObject {

    final float MAX_X_VELOCITY...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Android Game Programming By Example
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon