Defining our variables

We define our variables required by adding our desired variables, such as rockStartTime, rocks, and rnd:

public static final int WIDTH = 1920;public static final int HEIGHT = 1080;public static final int MOVINGSPEED = -5;private long rockStartTime;private MainGameThread mainThread;private BackgroundImage bgImg;private PlayerCharacter playerCharacter;private ArrayList<Rock> rocks;private Random rnd = new Random();

These variables give us references of objects to work with.

Get Learning Android Game Development now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.