Exercise - Make the player consume food

Completed

Your goal is to develop a mini-game application. The mini-game displays food that the player can consume. You need to detect if the player has successfully consumed the food, and if so, redisplay the food. You also want to change the player appearance depending on what food was consumed.

Specification

In this challenge exercise, you need to create a method that determines if the player has consumed the food that was displayed. If the food was consumed, you want to update the player's appearance and redisplay the food.

Check if the player consumed the food

  • Create a method that uses the existing position variables of the player and food
  • The method should return a value
  • After the user moves the character, call your method to determine the following:
    • Whether or not to use the existing method that changes player appearance
    • Whether or not to use the existing method to redisplay the food

Check your work

To validate that your code satisfies the specified requirements, complete the following steps:

  1. Use Visual Studio Code to build and run your app.

    Note

    You can exit the verification test before completing all of the verification steps if see a result that does not satisfy the specification requirements. To force an exit from the running program, in the Terminal panel, press Ctrl-C. After exiting the running app, complete the edits that you believe will address the issue you are working on, save your updates to the Program.cs file, and then re-build and run your code.

  2. At the Terminal command prompt, press directional keys to move the player.

  3. Move the player across the displayed food string.

  4. Verify that a new food string is displayed.

  5. Verify that the player appearance changes depending on which food string was consumed.

Once you've validated the results for this exercise, proceed to the next exercise in this challenge.