Putting everything together

We just need to tie up a few loose ends and we will at last be able to run the game.

Updating GameEngine

Add an instance of the Level class to GameEngine.

...
HUD mHUD;
Renderer mRenderer;
ParticleSystem mParticleSystem;
PhysicsEngine mPhysicsEngine;
Level mLevel;

Initialize the instance of Level in the GameEngine constructor.

public GameEngine(Context context, Point size) {
   super(context);

   mUIController = new UIController(this, size);
   mGameState = new GameState(this, context);
   mSoundEngine = new SoundEngine(context);
   mHUD = new HUD(size);
   mRenderer = new Renderer(this);
   mPhysicsEngine = new PhysicsEngine();

   mParticleSystem = new ParticleSystem();
   mParticleSystem.init(1000);

   mLevel = new Level(context,
 new PointF(size.x, ...

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.