Need help with an assignment from school

Now that we have seen the code you have already, we have a much better idea of where you are in your project! You don;t need help with the basics - your question is much more specific now!

The next thing you should add is a function that determines in the player is touching the coin. It should look like this:

boolean is_player_on_coin(){
  /// Returns true if the player is on the coin, or false otherwise.
  // TODO: Make this function return true sometimes!
  return( false );
}

You will need to write the body of this function yourself. What can you say about the position of the coin in relation to the position and size of the player when they are touching?

Here’s an image that might help you visualize it:

DoesCollide

Try writing this function yourself now. Use an if statement!

Once you have written this function, can you use it? How often do you need to check for the player collecting the coin? What happens if the player collects the coin? You will need another if statement!

4 Likes