Since we have already created our collision method, we simply go ahead and use the function. We already have a clear understanding of how a collision works because of the previous chapter, so we write the following code in our update() method of our GameView.java file:
for(int i=0; i<lowerBoundary.size();i++) { if(collision(lowerBoundary.get(i),playerCharacter)) { playerCharacter.setPlaying(false); }}for(int i=0; i<upperBoundary.size();i++) { if(collision(upperBoundary.get(i),playerCharacter)) { playerCharacter.setPlaying(false); }}
Collision detection between the player and the ground is completed. Now, we also have to assign our maximum and minimum boundary heights as well as tweak them ...