zopiac

Game Alpha

Oct 6th, 2010
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.10 KB | None | 0 0
  1. //NULL: How to compact: "while ((command.equals("n")) || (command...."
  2. //How to consolidate the intense number of  "if (x == 10 && y == 10) {" etc. groups cleanly
  3. import java.util.Scanner;
  4. public class Testing {
  5.     public static void name( String args[]) {
  6.         Scanner input = new Scanner(System.in);
  7.         System.out.println("What is your name, hero?");
  8.         String hero1Name = input.nextLine();
  9.         System.out.println("Welcome to Castle Alpha, " + hero1Name +"!");
  10.         System.out.println("What is the name of your companions?");
  11.         System.out.println("What is your companion's name?");
  12.         String hero2Name = input.nextLine ();
  13.         System.out.println("Welcome to the party, " + hero2Name + "!");
  14.     }
  15.     public static void main( String args[]) {
  16.         Scanner input = new Scanner(System.in);
  17.         int x = 10;
  18.         int y = 10;
  19.         int area = 1;
  20. //      int numCommand = 0;
  21.         String command = "";
  22.         while (area == 1) {
  23.             if (x == 10 && y == 10) {
  24.                 System.out.println(x + ", " + y + "\nYou are in the town centre.\nYou may go north, east, south, or west.");
  25.                 System.out.println("Command?");
  26. ////////////////Numerical movement system:
  27. //              numCommand = input.nextInt();
  28. //              System.out.println(command);
  29. //              while ((numCommand == 8) || (numCommand == 2) || (numCommand == 4) || (numCommand == 6)) {
  30. //                  if (numCommand == 8) {
  31. //                      y = y + 1;
  32. //                      numCommand = 0;
  33. //                  } else if (numCommand == 2) {
  34. //                      y = y - 1;
  35. //                      numCommand = 0;
  36. //                  } else if (numCommand == 4) {
  37. //                      x = x - 1;
  38. //                      numCommand = 0;
  39. //                  } else if (numCommand == 6) {
  40. //                      x = x + 1;
  41. //                      numCommand = 0;
  42. //                  }
  43. ////////////////
  44.                 command = input.nextLine();
  45.                 while (!command.equals("")) {
  46. //              while ((command.equals("n")) || (command.equals("s")) || (command.equals("e")) || (command.equals("w"))) {
  47.                     if (command.equals("n")) {
  48.                         y = y + 1;
  49.                         command = "";
  50.                     } else if (command.equals("s")) {
  51. //                      y = y - 1;
  52.                         System.out.println("Unavailable at this time.");
  53.                         command = "";
  54.                     } else if (command.equals("w")) {
  55. //                      x = x - 1;
  56.                         System.out.println("Unavailable at this time.");
  57.                         command = "";
  58.                     } else if (command.equals("e")) {
  59. //                      x = x + 1;
  60.                         System.out.println("Unavailable at this time.");
  61.                         command = "";
  62.                     } else {
  63.                         System.out.println("Unrecognised command. Try again.");
  64.                         command = input.nextLine();
  65.                     }
  66.                 }
  67.             } if (x == 10 && y == 11) {
  68.                 System.out.println(x + ", " + y + "\nYou are on Main Street, north of the town centre.\nYou may go north or south.\nThere is a General Store to your west.");
  69.                 System.out.println("Command?");
  70.                 command = input.nextLine();
  71.                 while (!command.equals("")) {
  72. //              while ((command.equals("n")) || (command.equals("s")) || (command.equals("e")) || (command.equals("w"))) {
  73.                     if (command.equals("n")) {
  74. //                      y = y + 1;
  75.                         System.out.println("Unavailable at this time.");
  76.                         command = "";
  77.                     } else if (command.equals("s")) {
  78.                         y = y - 1;
  79.                         command = "";
  80.                     } else if (command.equals("w")) {
  81. //                      x = x - 1;
  82.                         System.out.println("Unavailable at this time.");
  83.                         command = "";
  84.                     } else if (command.equals("e")) {
  85. //                      x = x + 1;
  86.                         System.out.println("You cannot go that way.");
  87.                         command = "";
  88.                     } else {
  89.                         System.out.println("Unrecognised command. Try again.");
  90.                         command = input.nextLine();
  91.                     }
  92.                 }
  93.             }
  94. //              } else if (x == 10 && y == 9); {
  95. //                  System.out.println(x + ", " + y + "\nYou may go north or south.");
  96.         }
  97.         while (area == 2) {
  98.             ////STATEMENT RESERVED FOR AREA 2
  99.         }
  100.         while ((area != 1) || (area != 2)) {
  101.             ////TEMPORARY STATEMENT CONCERNING INVALID AREAS
  102.             System.out.println("Area does not exist");
  103.         }
  104.         System.out.println("TERMINATING");
  105.     }
  106. }
  107.  
  108. //              //CHARACTER VARIABLE DECLARATION
  109. //                int health = 100;
  110. //                int mana = 100;
  111. //                int stamina = 100;
  112. //                int STR = 10;
  113. //                int CON = 10;
  114. //                int INT = 10;
  115. //                int WIS = 10;
  116. //                int DEX = 10;
  117. //                int CHA = 10;
Add Comment
Please, Sign In to add comment