CODE CREATIVE
HERO & MONSTERS
Destroy them all...
TASK #1
Watch the video below to get an idea of what you are being asked to build.
TASK #2
TASK:
Create the map.

HINT:
You will need to either create a 2D array of characters and have each character represent an object that you have stored elsewhere, or you can create a 2D array of Objects and store the objects directly into the array at their location in the map. Object is a superclass of all classes in Java and can be used as a generic placeholder for an object of any class.

CHECK UP:
Watch the video below to check that you completed the task.
TASK #3
TASK:
Create Hero class.

HINT:
You will need to create a Hero class and think about the different instance fields your hero will need. You will definitely need an x position and y position on the map, along with a health attribute.

CHECK UP:
Watch the video below to check that you completed the task.


CHALLENGE EXERCISE #1
  1. Create all the other classes.
  2. Create your objects.




TASK #4
TASK:
Fill the 2D array with the objects that you have created.

HINT:
You will need to set the column and row position of on the map using each object's (xPos, yPos) instance field value and set that location equal to the object. You will also need to place each object in the 2D array in such a way that objects are not overlapping. An easy way to accomplish this is to use a while loop that places at random locations and reiterates if that location is occupied.

CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGE EXERCISE #2
  1. Check if each object's randomly generated x & y locations are already taken on the map.
TASK #5
TASK:
Take in directional input from the user repeatedly.

HINT:
You will need to create a Scanner object and read in the user’s choice. Remember that within every video game, contains a while loops that iterates for the length of the game. Hero & Monsters is no different and every iteration of this loop should read in the user’s directional choice and act accordingly.

CHECK UP:
Watch the video below to check that you completed the task.


CHALLENGE EXERCISE #3
  1. Error check the directional input so the user can’t go off the map.
  2. Error check the directional input so the user must type in wasd in lowercase.




TASK #6
TASK:
Update the position of the hero object in the map and create a function that prints out the current state of the map.

HINT:
You will need to create a branch statement that runs different blocks of code based on the user's input. For each branch, you will need to adjust the hero's xPos and yPos accordingly. Don't forget that before you do, you must error check the desired direction as we cannot allow the hero to leave the map. To print out the map, you will need to create a nested for loop that prints out each element in the 2D array.

CHECK UP:
Watch the video below to check that you completed the task.


CHALLENGE EXERCISE #4
  1. Check whether the hero is standing next to an object and if so, interact with the object.
  2. Build a fighting system for when hero is standing next to a monster.
  3. Program the other functionalities in the description.




CHALLENGE EXERCISE #5
  1. Add any additional functionalities you feel are necessary.
  2. Code the ending.



Congratulations, you have completed the Hero & Monsters project!