import java.util.Scanner;
import java.util.*;
/**
* This a program or a maze game that incorporates some of the code that we have learned
* @author Bryson Hori
*
*/
public class BrysonHori_6
{
public static void main(String[] args) {
Scanner keybd = new Scanner(System.in);
final int MAZE_WIDTH = 10;
final int MAZE_HEIGHT = 10;
final String FLOOR = ".";
final char PLAYER = 'P';
final char EXIT = 'X';
System.out.println("This is a maze game.");
System.out.println("The point of the game is for the player to get out of a room that is" + MAZE_WIDTH + " by " + MAZE_HEIGHT);
System.out.println("This is done by pressing keys w,a,s,d");
System.out.println("The direction north,south,east and west:");
System.out.println("north = up");
System.out.println("west = left");
System.out.println("south = down");
System.out.println("east = right");
System.out.println("The capitol letter P represens you the player and the capitol letter X represents the exit.");
System.out.println("");
double mazeExitY = (int) (Math.random() * MAZE_HEIGHT);
double mazePlayerX = (int)(Math.random() * MAZE_WIDTH);
double mazePlayerY = (int)(Math.random() * MAZE_HEIGHT);
for (int y = 0; y <= MAZE_HEIGHT; y++) {
for (int x = 0; x <= MAZE_WIDTH; x++) {
if ( x == mazePlayerX && y == mazePlayerY) {
System.out.print(PLAYER);
}else if (y == mazeExitY) {
System.out.print(EXIT);
}else {
System.out.print(FLOOR);
}
}
System.out.println();
}
String again = "y";
while(again.equalsIgnoreCase("y") || again.equalsIgnoreCase("yes")){
System.out.println("");
System.out.println("What direction do you what to go?");
String direction = keybd.next();
if (direction.equalsIgnoreCase("west")){
mazePlayerY = mazePlayerY -1;
}if (direction.equalsIgnoreCase("east")){
mazePlayerY = mazePlayerY +1;
}if (direction.equalsIgnoreCase("north")){
mazePlayerX = mazePlayerX -1;
}if (direction.equalsIgnoreCase("south")){
mazePlayerX = mazePlayerX +1;
}
for (int y = 0; y <= MAZE_HEIGHT; y++) {
for (int x = 0; x <= MAZE_WIDTH; x++) {
if ( x == mazePlayerX && y == mazePlayerY) {
System.out.print(PLAYER);
}else if (y == mazeExitY) {
System.out.print(EXIT);
}else {
System.out.print(FLOOR);
}
}
System.out.println();
}
}
}
}