Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package roomgame;
- import java.util.Scanner;
- public class RoomGame
- {
- private static String[][][] Room = new String[5][5][2];
- private static int Row = 0;
- private static int Column = 0;
- private static int Depth = 0;
- private static int HP = 100;
- private static int Damage = 20;
- private static int RandoNumber = 0;
- private static int min = 1;
- private static int max = 2;
- private static int range = 0;
- private static int TheRandomNumberDamage = 0;
- private static int Gold = 0;
- private static int minGold = 1;
- private static int maxGold = 100;
- private static int rangeGold = 0;
- private static int RandomGold = 0;
- public static void main(String[] args)
- {
- System.out.println("This is a program that makes you play a maze game");
- RoomGame bob = new RoomGame();
- bob.One();
- }
- private void One()
- {
- System.out.println("The controls are to move North, East, South, West");
- Assigning();
- System.out.println("You may lose HP or encounter gold in this maze, beware");
- System.out.println("Your HP is " + HP);
- System.out.println("Your Gold is " + Gold);
- Calculating();
- }
- private void Assigning()
- {
- range = (max-min)+1;
- rangeGold = (maxGold - minGold) + 1;
- Room[0][0][0] = "You are in dark room. You see a light ahead"; //room 0
- Room[0][0][1] = "You can move North";
- Room[1][0][0] = "It's so bright with candles. It's blinding me"; //room 1
- Room[1][0][1] = "You can move North or East";
- Room[2][0][0] = "There is a strange smell. Perhaps a forest is nearby?"; //room 2
- Room[2][0][1] = "You can move East or South";
- Room[2][1][0] = "The room has trees in it. They're prickly"; //room 3
- Room[2][1][1] = "You can move West, South, or East";
- Room[1][1][0] = "The room is very purple. How Strange"; //room 5
- Room[1][1][1] = "You can move West, North, or East";
- Room[1][2][0] = "The room is orange. How strange"; //room 6
- Room[1][2][1] = "You can move West, North, or East";
- Room[2][2][0] = "The room is white. How strange"; //room 7
- Room[2][2][1] = "You can move North, West, South, or East";
- Room[2][3][0] = "The room is pink. How strange"; //room 8
- Room[2][3][1] = "You can move West";
- Room[3][2][0] = "You've reached the final room. Congratulations!"; //room 4
- Room[3][2][1] = "You can move back south, if you wish";
- }
- private void Calculating()
- {
- Scanner AnnieBot = new Scanner(System.in);
- String Response = "";
- while(Row != 3 && Column != 2) //while not reached final room
- {
- System.out.println(Room[Row][Column][Depth]);
- System.out.println(Room[Row][Column][Depth+1]);
- Response = AnnieBot.nextLine();
- if((Response.equals("North") || Response.equals("East") || Response.equals("South") || Response.equals("West"))) //if it's a proper input
- {
- if(Response.equals("North"))
- {
- Row++;
- System.out.println("You are now in room " + Row + "," + Column + "," + Depth);
- }
- if(Response.equals("East"))
- {
- Column++;
- System.out.println("You are now in room " + Row + "," + Column + "," + Depth);
- }
- if(Response.equals("South"))
- {
- Row--;
- System.out.println("You are now in room " + Row + "," + Column + "," + Depth);
- }
- if(Response.equals("West"))
- {
- Column--;
- System.out.println("You are now in room " + Row + "," + Column + "," + Depth);
- }
- // beginner ifs or
- if ((Row == 4 || Column == 3 || Row < 0 || Column < 0) || ((Row == 0 && Column == 1 || Row == 0 && Column == 2 || Row == 1 && Column == 3 || Row == 2 && Column == 4) || Row == 3 && Column == 0 || Row == 3 && Column == 1 || Row == 3 && Column == 3))
- {
- System.out.println("Not valid input. Try again");
- Calculating();
- }
- TheRandomNumberDamage = ((int)(Math.random()*range)+min);
- if(TheRandomNumberDamage == 0)
- {
- HP+=Damage;
- System.out.println("Ouch! You took 20 damage points, you are now at " + 100 + " HP");
- }
- TheRandomNumberDamage = ((int)(Math.random()*range)+min);
- if(TheRandomNumberDamage == 1)
- {
- RandomGold = ((int)(Math.random()*rangeGold)+minGold);
- Gold += RandomGold;
- System.out.println("You've gained " + RandomGold + " gold and you now have " + Gold);
- }
- }
- else
- {
- System.out.println("Not valid input. Try again");
- Calculating();
- }
- } //end while
- }//end main
- } //end class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement