Coding the detectCollisions method: Part 1
All the code for handling collisions will go in the detectCollisions
method. There is quite a large amount of code so let's split it up into two parts.
And once we have added the code for each part we will further sub-divide it to make sure we know how it works.
To get started, add the following code. Study it in detail as you proceed and note where the comment // More code here next
is.
private void detectCollisions(GameState gs, ArrayList<GameObject> objects) { // More code here soon boolean collisionOccurred = false; // Something collides with some part of // the player most frames // so, let's make some handy references // Get a reference to the players position // as we will probably need to update it Transform playersTransform = objects.get(LevelManager.PLAYER_INDEX) .getTransform(); PlayerTransform playersPlayerTransform = (PlayerTransform) playersTransform...