Declaring and Initializing the Sub' Hunter Variables

We know lots about variables, types and how to manipulate them but we haven't considered what variables and types the Sub' Hunter game will need. It will help to first consider all the different values and types we need to keep track of and manipulate, then we can come up with a list of names and types before actually adding the declaration code to the project. After that, we will initialize the variables.

Planning the variables

Let's have a think about what our game needs to keep track of. This will dictate the variables, types, and names that we will declare.

  • We need to know how many pixels wide and high the screen is comprised of. We will call these variables numberHorizontalPixels and numberVerticalPixels ...

Get Learning Java by Building Android Games - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.