020000000000 010111111110 010010000010 010010101010 011111111010 000000000030
import javax.swing.JOptionPane; public class aMazeGame { //Declarations : This is where all the variables are declared //which need to be available to several methods char anyChar, starter; int userInput = 0; char mover; public static final char[][] array = null; static int rows; static int cols; // variables to get the numbers of rows and columns from my text file enum Direction {NORTH, SOUTH, EAST, WEST}; public static void main(String[] args) { menu(); } public static void menu (){ int userInput; TextIO.putln("MazeGame"); TextIO.putln(); TextIO.putln(); TextIO.putln("Please select an Option :"); TextIO.putln("1 - to Play the Game"); TextIO.putln("2 - for Instructions"); TextIO.putln("3 - to Exit the Game"); userInput = TextIO.getlnInt(); switch (userInput){ case 1 : playGame(); case 2 : instructions(); case 3 : endGame(); default : NotA(); } //return userInput; } public static void playGame() { // make it all work beMaze (); player(); } public static void instructions() { // Display instructions char anyChar; TextIO.putln(); TextIO.putln("Controls"); TextIO.putln(); TextIO.putln("Move your player with these keys :"); TextIO.putln("W - Up"); TextIO.putln("S - Down"); TextIO.putln("D - Right" ); TextIO.putln("A - Left"); TextIO.putln("* = Your Player"); TextIO.putln(); TextIO.putln("Press any key to continue"); anyChar = TextIO.getAnyChar(); menu(); } public static void endGame() { System.exit(0); } public static void NotA() { char anyChar; menu(); } public static void beMaze(){ TextIO.putln(); TextIO.putln(); TextIO.putln(); TextIO.readFile("C:\\Users\\Elliot\\Documents\\New folder\\sample_maze2.txt"); int rows = TextIO.getInt(); //variables to get the numbers of rows and int cols = TextIO.getInt(); // columns from my text file int[][] array = new int[25][39]; // this will create a 2-dimension array with the data //from my rows and columns in my maze text file //this bit dictates the size of the array for (int i=0; i < rows; i++) { for (int j=0; j < cols; j++) { //this bit fills the array with the corresponding data array[i][j] = TextIO.getChar(); } TextIO.getln(); } TextIO.readStandardInput(); // This tells the prog the file is done and can be closed //this section displays my maze using blocks for (int i=0; i < rows; i++) { for (int j=0; j < cols; j++) { if (array[i][j]=='0') TextIO.putf("O"); if (array[i][j]=='1') TextIO.putf(" "); if (array[i][j]=='2') TextIO.putf("*"); if (array[i][j]=='3') TextIO.putf("X"); } TextIO.putln(); } } //I want the section below to be the part where the input to move the player happens. public static void player() { TextIO.putln(); TextIO.putln(); TextIO.putln("Where would you like to move?"); char starter = TextIO.getChar(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)