Reader small image

You're reading from  Learning Java by Building Android Games - Third Edition

Product typeBook
Published inMar 2021
Reading LevelBeginner
PublisherPackt
ISBN-139781800565869
Edition3rd Edition
Languages
Right arrow
Author (1)
John Horton
John Horton
author image
John Horton

John Horton is a programming and gaming enthusiast based in the UK. He has a passion for writing apps, games, books, and blog articles. He is the founder of Game Code School.
Read more about John Horton

Right arrow

Coding the player's and the background's empty component classes

Coding an empty class for each player-related component will allow us to quickly write the code to get the game running. We can then flesh out the real/full code for each component as we proceed, without the need to dip into the same class (mainly GameObject) multiple times.

In this chapter, we will deal with the player (and their lasers) and the background. Coding the empty outlines will also allow us to code an error-free GameObject class that will hold all these components. By doing this, we can see how the components interact with the game engine via the GameObject class before we code the details inside each component.

Each of the components will implement one of the interfaces we coded in the previous section. We will add just enough code for each class to fulfill its contractual obligations to the interface and thus not cause any errors. We will also make very minor changes outside the component...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning Java by Building Android Games - Third Edition
Published in: Mar 2021Publisher: PacktISBN-13: 9781800565869

Author (1)

author image
John Horton

John Horton is a programming and gaming enthusiast based in the UK. He has a passion for writing apps, games, books, and blog articles. He is the founder of Game Code School.
Read more about John Horton