Drawing our boundaries on the screen

As with our previous images, we use the draw() method to write our code for displaying our ground on the screen:

for(UpperBoundary ub : upperBoundary){    ub.draw(canvas);}for(LowerBoundary lb: lowerBoundary) {    lb.draw(canvas);}

Even this part is taken care of for now. Now, we have to look at the collision part of our ground. We need to detect a collision on our ground with the player. 

Get Learning Android Game Development 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.