Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //***VERSION 1.1****
- import java.util.Scanner; // import so we can use the scanner to monitor input
- public class text {
- //example of original text based game
- //http://www.web-adventures.org/cgi-bin/webfrotz?s=ZorkDungeon
- //GLOBAL VARIABLES can be seen EVERYWHERE
- // INVENTORY
- //To create an inventory
- public static boolean sword=false; //now we have a sword variable
- // a boolean is a variable that can be either true or false
- //we can check if we have the item by seeing if item is true or false
- public static boolean armor=false;
- public static boolean coin=false;
- public static boolean Document=false;
- public static boolean BabyHippo=false;
- public static boolean Q1=false;
- public static boolean Q2=false;
- //SUGGESTION
- //-draw out your game before hand label with the names you will use for the methods of each area
- public static void main(String[] args){
- System.out.println("You can not use caps in this game");
- System.out.println("");
- // we are in java so when a program starts we do the main method first
- levelone();//we call the leveone function so now we go into that function
- }
- private static String getinput() {// this is a function we use to get input from the player
- Scanner keyboard= new Scanner(System.in); // we make a listener called keyboard
- String input= keyboard.nextLine(); // we set a variable of type string to equal the players input
- return input; // now we return the string the player typed in to the place that called this function
- //IMPORTANT ****this only takes the string up to the first space****
- // if you want to take past the first space switch this to keyboard.nextLine()
- }
- private static void levelone() {
- System.out.println("You are in the ruins of your village");
- System.out.println("A village elder explains that Rampaging hipos have destroyed your village, and that he needs you to come talk when ready.");
- String playerinput=getinput(); // setting our variable, playerinput, of type String, to what the player types in
- System.out.println(playerinput);
- if(playerinput.contains("talk")){
- System.out.println("I need you to go Boolean city and ask for aid.");
- leveltwo();
- }
- else if (playerinput.contains("ready")){
- System.out.println("I need you to go to Boolean city and ask for aid.");
- System.out.println("You recieved quest:Village Aid!");
- leveltwo();
- }
- else{
- System.out.println("Invalid move, you bumbling buffoon.");
- levelone();
- }
- }
- private static void leveltwo() {
- System.out.println("You exit the village entering a grassy field");
- System.out.println("You see a cross road runs throug the path showing 3 directions: South,North and West");
- String playerinput=getinput();
- if
- (playerinput.equalsIgnoreCase("North")){
- levelthree();
- }
- else if
- (playerinput.equalsIgnoreCase("West")){
- levelfour();
- }
- else if
- (playerinput.equalsIgnoreCase("South")){
- levelsix();
- }
- else{
- System.out.println("Invalid move, you bumbling buffoon.");
- leveleight();
- }
- }
- private static void levelthree() {
- System.out.println("Heading north you arive at the city of boolean.");
- String playerinput=getinput();
- if(playerinput.contains("enter")){
- System.out.println("Guard:Only those with the proper documents may pass.");
- if (Document == true){
- System.out.println("Guard: Oh you have them, you may pass");
- leveltwo();
- }
- else {
- System.out.println("Guard: You have no papers, SCRAM!");
- leveleight();
- }
- }
- else if
- (playerinput.contains("south")){
- leveleight();
- }
- else{
- System.out.println("Invalid move, you bumbling buffoon");
- levelthree();
- }
- }
- private static void levelfour() {
- System.out.println("You arive in a open plain");
- System.out.println("Either Explore or leave");
- String playerinput=getinput();
- if (playerinput.contains("explore")){
- System.out.println(" you find a man fighting a ugly looking hippo.");
- System.out.println("Either aid him or flee");
- }
- else if(playerinput.contains("leave")){
- System.out.println("You leave wondering what you could have found");
- leveleight();
- }
- else if(playerinput.contains("aid")){
- System.out.println("You reach the man just as he collapses, you slay the hippo with his sword");
- System.out.println("You gained: The Sword!");
- sword=true;
- levelfive();
- }
- else if
- (playerinput.contains("flee")){
- System.out.println("You Escaped!");
- leveleight();
- }
- else{
- System.out.println("Invalid move, you bumbling buffoon.");
- levelfour();
- }
- }
- private static void levelfive() {
- System.out.println("Fallen Man: I tracked the beast after it attacked my village, south of the crossroads.");
- System.out.println("Fallen Man: Please let them know where I am");
- System.out.println("");
- System.out.println("You recieved Quest:Help me");
- leveleight();
- }
- private static void levelsix() {
- System.out.println("Heading south you find a rocky canyon entrance that has been blocked by a boulder.");
- System.out.println("search around for a way around or leave?");
- String playerinput=getinput();
- if (playerinput.contains("leave")){
- leveleight();
- }
- else {
- System.out.println("You find nothing while searching.");
- levelseven();
- }
- }
- private static void levelseven() {
- System.out.println("Keep searching or leave?");
- String playerinput=getinput();
- if(playerinput.contains("keep searching")){
- System.out.println("You find a small cave entrance and enter it");
- leveltwo();
- }
- else{
- System.out.println("You give up heading back.");
- levelnine();
- }
- }
- private static void leveleight() {
- System.out.println("You see a cross road runs throug the path showing 3 directions: South,North and West");
- String playerinput=getinput();
- if
- (playerinput.equalsIgnoreCase("North")){
- levelthree();
- }
- else if
- (playerinput.equalsIgnoreCase("West")){
- levelfour();
- }
- else if
- (playerinput.equalsIgnoreCase("South")){
- levelsix();
- }
- else{
- System.out.println("Invalid move, you bumbling buffoon.");
- leveleight();
- }
- }
- private static void levelnine() {
- System.out.println("Entering into the cave you quickly become entangled in the spider webs hanging every where");
- if (sword==true) {
- System.out.println("Your sword easily slices through the webs allowing you to free yourself");
- System.out.println("However the blade snaps as you finish making you sad :(");
- sword=false;
- levelten();
- }
- else {
- System.out.println("Not being able to free yourself you black out from a lack of oxygen.");
- levelone();
- }
- }
- private static void levelten() {
- System.out.println("Having escaped you hurry down the tunnel and burst out onto another adbandoned cross road.");
- System.out.println("You have three options: Go up,right or left.");
- String playerinput=getinput();
- if (playerinput.contains("up")){
- System.out.println("Heading up the hill you find and climb into a empty watch tower made of wood.");
- leveleleven();
- }
- else if (playerinput.contains("right")){
- System.out.println("Turning right you find a dead end, you turn around dejected.");
- leveltwelve();
- }
- else if (playerinput.contains("left")){
- System.out.println("Turning left you find the village burning, quickly you rush to it's aid.");
- }
- }
- private static void leveleleven() {
- }
- private static void leveltwelve() {
- System.out.println("You come back out of the dead end feeling sad.");
- System.out.println("You have three options: Go up,right or left.");
- String playerinput=getinput();
- if (playerinput.contains("up")){
- System.out.println("Heading up the hill you find and climb into a empty watch tower made of wood.");
- leveleleven();
- }
- else if (playerinput.contains("right")){
- System.out.println("Turning right you find a dead end, you turn around dejected.");
- leveltwelve();
- }
- else if (playerinput.contains("left")){
- System.out.println("Seeing a ploom of smoke coming from around the side of the cliff you hurry to the village. ");
- levelxy();
- }
- else {
- System.out.println("Invalid move, you bumbling buffon");
- leveltwelve();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement