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

Testing the game

Now, we can run the game in the usual way. Notice the subHorizontalposition and subVerticalPosition variables in the following abbreviated logcat output:

subHorizontalPosition: 30
subVerticalPosition: 13

Try running the game again; you will get different positions, demonstrating that our Random-based code is working and that we can confidently call newGame whenever we want to start a new game:

subHorizontalPosition: 14
subVerticalPosition: 7

Important note

It is possible but very unlikely that you can call the newGame method and get a sub' in the same position.

That's it – now, we can spawn our sub' each new game!

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