Present the program to the class or demo to instructor during open lab.

Develop a theme for your game which allows for the enemies to move and attack the player and the player can attack the enemies.  Implement multiple enemies in an ArrayList.  Implement other variables in your classes such as gold, weapons, or armor.  The code below should help you get started.

import java.util.*;
public class game
{
   public static void main (String[] args)
   {
      Scanner in = new Scanner(System.in);
      String Choice = "";

      // creating the player will initialize the world
      Player P = new Player("Kirk");

      // create an ArrayList of enemies and add some
      ArrayList<Enemy> Enemies = new ArrayList<Enemy>();
      Enemies.add(new Enemy("Orc"));
      Enemies.add(new Enemy("Dragon"));
      
      while (!Choice.equals("q") && P.HP >= 0)
      {
         P.PrintWorld();
         System.out.print("Enter your command: ");
         Choice = in.nextLine();

         // player move
         if (Choice.equals("a"))
            P.MoveLeft();
         if (Choice.equals("d"))
            P.MoveRight();
         if (Choice.equals("w"))
            P.MoveUp();
         if (Choice.equals("s"))
            P.MoveDown();
 
         // Step through Enemy ArrayList and attack if adjacent to player
         for (int i=0; i<Enemies.size(); i++)
         {
            if ((Enemies.get(i).Ypos == P.Ypos && (Enemies.get(i).Xpos == P.Xpos+1)) || // player is to the left
               (Enemies.get(i).Ypos == P.Ypos && (Enemies.get(i).Xpos == P.Xpos-1)) ||  // player is to the right
               (Enemies.get(i).Xpos == P.Xpos && (Enemies.get(i).Ypos == P.Ypos+1)) ||  // player is above
               (Enemies.get(i).Xpos == P.Xpos && (Enemies.get(i).Ypos == P.Ypos-1)))    // player is below
            {
               Enemies.get(i).HP -= P.Attack;    // Player attacks Enemy
               P.HP -= Enemies.get(i).Attack;    // Enemy attacks Player
               // Here is a more advanced attack formula that utilizes attack and armor values.
               // P.HP -= (100 * Enemy.get(i).Attack) / (100 + P.Armor)

               if (Enemies.get(i).HP <= 0)    // Enemy dies    
               {
                  P.World[Enemies.get(i).Xpos][Enemies.get(i).Ypos] = ' ';
                  Enemies.remove(i);
               }
            }
         }
         // Step through Enemy ArrayList and move towards the player
         for (int i=0; i<Enemies.size(); i++)
         {
            if (Enemies.get(i).Xpos > P.Xpos)
               Enemies.get(i).MoveLeft();
            else
               Enemies.get(i).MoveRight();
            if (Enemies.get(i).Ypos > P.Ypos)
               Enemies.get(i).MoveUp();
            else
               Enemies.get(i).MoveDown();
         }
      }
   }
}