Advertisement
anudrul

Text game two

Jul 11th, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.61 KB | None | 0 0
  1. //***VERSION 1.1****
  2. import java.util.Scanner; // import so we can use the scanner to monitor input
  3.  
  4.  
  5. public class text {
  6.  
  7.        
  8.        
  9.         //example of original text based game
  10.         //http://www.web-adventures.org/cgi-bin/webfrotz?s=ZorkDungeon
  11.                
  12.         //GLOBAL VARIABLES can be seen EVERYWHERE
  13.         // INVENTORY
  14.         //To create an inventory
  15.         public static boolean sword=false;  //now we have a sword variable
  16.         // a boolean is a variable that can be either true or false
  17.         //we can check if we have the item by seeing if item is true or false
  18.         public static boolean armor=false;
  19.        
  20.         public static boolean coin=false;
  21.        
  22.         public static boolean Document=false;
  23.        
  24.         public static boolean BabyHippo=false;
  25.        
  26.         public static boolean Q1=false;
  27.        
  28.         public static boolean Q2=false;
  29.        
  30.        
  31.        
  32.         //SUGGESTION
  33.         //-draw out your game before hand label with the names you will use for the methods of each area
  34.        
  35.        
  36.         public static void main(String[] args){
  37.                System.out.println("You can not use caps in this game");
  38.                System.out.println("");
  39.              
  40.                
  41.                 // we are in java so when a program starts we do the main method first
  42.                 levelone();//we call the leveone function so now we go into that function
  43.        
  44.         }
  45.  
  46.         private static String getinput() {// this is a function we use to get input from the player
  47.                 Scanner keyboard= new Scanner(System.in); // we make a listener called keyboard
  48.                 String input= keyboard.nextLine();                      // we set a variable of type string to equal the players input
  49.                 return input;                                   // now we return the string the player typed in to the place that called this function
  50.                
  51.         //IMPORTANT ****this only takes the string up to the first space****
  52.                 // if you want to take past the first space switch this to keyboard.nextLine()
  53.                
  54.         }
  55.        
  56.         private static void levelone() {
  57.                 System.out.println("You are in the ruins of your village");
  58.             System.out.println("A village elder explains that Rampaging hipos have destroyed your village, and that he needs you to come talk when ready.");
  59.                 String playerinput=getinput(); // setting our variable, playerinput, of type String, to what the player types in
  60.             System.out.println(playerinput);
  61.             if(playerinput.contains("talk")){
  62.                System.out.println("I need you to go Boolean city and ask for aid.");                  
  63.                 leveltwo();
  64.             }
  65.             else if (playerinput.contains("ready")){
  66.                 System.out.println("I need you to go to Boolean city and ask for aid.");
  67.                 System.out.println("You recieved quest:Village Aid!");
  68.                  leveltwo();
  69.         }
  70.            
  71.            
  72.                
  73.                 else{
  74.                         System.out.println("Invalid move, you bumbling buffoon.");
  75.                         levelone();
  76.                 }
  77.         }
  78.  
  79.         private static void leveltwo() {
  80.                 System.out.println("You exit the village entering a grassy field");
  81.                 System.out.println("You see a cross road runs throug the path showing 3 directions: South,North and West");
  82.                 String playerinput=getinput();
  83.                
  84.                 if
  85.                    (playerinput.equalsIgnoreCase("North")){
  86.                         levelthree();
  87.                 }
  88.        
  89.                 else if
  90.                         (playerinput.equalsIgnoreCase("West")){
  91.                     levelfour();
  92.                 }
  93.            
  94.                 else if
  95.                      (playerinput.equalsIgnoreCase("South")){
  96.                          levelsix();
  97.                 }
  98.                
  99.                 else{
  100.                         System.out.println("Invalid move, you bumbling buffoon.");
  101.                       leveleight();
  102.                 }
  103.         }
  104.  
  105.         private static void levelthree() {
  106.                 System.out.println("Heading north you arive at the city of boolean.");
  107.                 String playerinput=getinput();
  108.                 if(playerinput.contains("enter")){
  109.             System.out.println("Guard:Only those with the proper documents may pass.");
  110.             if (Document == true){
  111.                 System.out.println("Guard: Oh you have them, you may pass");
  112.                   leveltwo();
  113.             }
  114.            
  115.             else {
  116.                 System.out.println("Guard: You have no papers, SCRAM!");
  117.                    leveleight();
  118.             }
  119.                        
  120.                 }
  121.                
  122.                
  123.                
  124.                 else if
  125.                      (playerinput.contains("south")){
  126.                            leveleight();
  127.                 }
  128.                
  129.                 else{
  130.                         System.out.println("Invalid move, you bumbling buffoon");
  131.                           levelthree();
  132.                 }
  133.                        
  134.        
  135.         }
  136.  
  137.         private static void levelfour() {
  138.                 System.out.println("You arive in a open plain");
  139.                 System.out.println("Either Explore or leave");
  140.             String playerinput=getinput();
  141.            
  142.             if (playerinput.contains("explore")){
  143.                 System.out.println(" you find a man fighting a ugly looking hippo.");
  144.                 System.out.println("Either aid him or flee");
  145.             }
  146.            
  147.             else if(playerinput.contains("leave")){
  148.                 System.out.println("You leave wondering what you could have found");
  149.                 leveleight();
  150.             }
  151.                  
  152.            
  153.                 else if(playerinput.contains("aid")){
  154.                 System.out.println("You reach the man just as he collapses, you slay the hippo with his sword");
  155.                 System.out.println("You gained: The Sword!");
  156.                 sword=true;
  157.                 levelfive();  
  158.             }
  159.            
  160.             else if
  161.                   (playerinput.contains("flee")){
  162.                   System.out.println("You Escaped!");
  163.                   leveleight();
  164.             }
  165.        
  166.             else{
  167.                 System.out.println("Invalid move, you bumbling buffoon.");
  168.                 levelfour();
  169.             }  
  170.         }
  171.        
  172.         private static void levelfive() {
  173.                 System.out.println("Fallen Man: I tracked the beast after it attacked my village, south of the crossroads.");
  174.                 System.out.println("Fallen Man: Please let them know where I am");
  175.                 System.out.println("");
  176.                 System.out.println("You recieved Quest:Help me");
  177.                 leveleight();
  178.                
  179.                
  180.         }
  181.  
  182.         private static void levelsix() {
  183.                 System.out.println("Heading south you find a rocky canyon entrance that has been blocked by a boulder.");
  184.                 System.out.println("search around for a way around or leave?");
  185.             String playerinput=getinput();
  186.            
  187.             if (playerinput.contains("leave")){
  188.                 leveleight();
  189.             }
  190.        
  191.             else {
  192.                 System.out.println("You find nothing while searching.");
  193.                 levelseven();
  194.          
  195.            
  196.            
  197.            
  198.        
  199.         }
  200. }
  201.  
  202.         private static void levelseven() {
  203.         System.out.println("Keep searching or leave?");
  204.         String playerinput=getinput();
  205.        
  206.         if(playerinput.contains("keep searching")){
  207.                 System.out.println("You find a small cave entrance and enter it");
  208.                 leveltwo();
  209.                 }
  210.        
  211.         else{
  212.                 System.out.println("You give up heading back.");
  213.                 levelnine();
  214.         }
  215.        
  216.        
  217.         }
  218.  
  219.         private static void leveleight() {
  220.                 System.out.println("You see a cross road runs throug the path showing 3 directions: South,North and West");
  221.                 String playerinput=getinput();
  222.                
  223.                 if
  224.                    (playerinput.equalsIgnoreCase("North")){
  225.                         levelthree();
  226.                 }
  227.        
  228.                 else if
  229.                         (playerinput.equalsIgnoreCase("West")){
  230.                     levelfour();
  231.                 }
  232.            
  233.                 else if
  234.                      (playerinput.equalsIgnoreCase("South")){
  235.                          levelsix();
  236.                 }
  237.                
  238.                 else{
  239.                         System.out.println("Invalid move, you bumbling buffoon.");
  240.                       leveleight();
  241.                 }
  242.         }
  243.  
  244.         private static void levelnine() {
  245.             System.out.println("Entering into the cave you quickly become entangled in the spider webs hanging every where");
  246.            
  247.            
  248.             if (sword==true) {
  249.                 System.out.println("Your sword easily slices through the webs allowing you to free yourself");
  250.                 System.out.println("However the blade snaps as you finish making you sad :(");
  251.                 sword=false;
  252.                 levelten();
  253.                
  254.             }
  255.            
  256.             else {
  257.                 System.out.println("Not being able to free yourself you black out from a lack of oxygen.");
  258.                 levelone();
  259.             }
  260.         }
  261.  
  262.         private static void levelten() {
  263.             System.out.println("Having escaped you hurry down the tunnel and burst out onto another adbandoned cross road.");
  264.             System.out.println("You have three options: Go up,right or left.");
  265.             String playerinput=getinput();
  266.        
  267.           if (playerinput.contains("up")){
  268.               System.out.println("Heading up the hill you find and climb into a empty watch tower made of wood.");
  269.               leveleleven();
  270.                }
  271.           else if (playerinput.contains("right")){
  272.               System.out.println("Turning right you find a dead end, you turn around dejected.");
  273.               leveltwelve();
  274.           }
  275.          
  276.           else if (playerinput.contains("left")){
  277.               System.out.println("Turning left you find the village burning, quickly you rush to it's aid.");
  278.              
  279.           }
  280.            
  281.         }
  282.  
  283.         private static void leveleleven() {
  284.            
  285.         }
  286.  
  287.         private static void leveltwelve() {
  288.             System.out.println("You come back out of the dead end feeling sad.");
  289.             System.out.println("You have three options: Go up,right or left.");
  290.             String playerinput=getinput();
  291.        
  292.           if (playerinput.contains("up")){
  293.               System.out.println("Heading up the hill you find and climb into a empty watch tower made of wood.");
  294.               leveleleven();
  295.                }
  296.           else if (playerinput.contains("right")){
  297.               System.out.println("Turning right you find a dead end, you turn around dejected.");
  298.               leveltwelve();
  299.              }
  300.          
  301.           else if (playerinput.contains("left")){
  302.               System.out.println("Seeing a ploom of smoke coming from around the side of the cliff you hurry to the village. ");
  303.               levelxy();
  304.           }
  305.            
  306.           else {
  307.               System.out.println("Invalid move, you bumbling buffon");
  308.               leveltwelve();
  309.           }
  310.        
  311.         }
  312. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement