I am currently in the process of coding a command-line adventure game in Java and wanted to share my progress so far on CTF ^^
Here's what I have:
Main class:
Quest1Accept:
Quest1Deny:
mayor1:
mayor2:
I will release the game here when it is finished (won't be for a while. It's going to be a big game.)
Yeah, it's mainly dialog because it's command line, but meh.
::blackhat::
Here's what I have:
Main class:
Code:
import java.util.Scanner;
public class gamemain {
public static void main(String[] args){
java.util.Scanner input = new java.util.Scanner(System.in);
gamesec obj1 = new gamesec();
Quest1Accept obj2 = new Quest1Accept();
Quest1Deny obj3 = new Quest1Deny();
String a;
String b;
int inv = 80;
int swrd = 25;
int boots = 40;
int shld = 30;
int swd = 1;
int bts = 2;
int shd = 3;
String i;
System.out.println("Hello there adventurer!");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("My name is Charlie. I will be your guide throughout your adventure.");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("Oh, I am so sorry. What is your name again?");
System.out.print("Name: ");
a = input.nextLine();
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("Oh. That's right. Well, let's get going, " + a + ".");
try{
Thread.sleep(3000);
}catch(InterruptedException e){
}
System.out.println("*You and Charlie travel to the village of Greyhaven.*");
try{
Thread.sleep(4000);
}catch(InterruptedException e){
}
System.out.println("Ah Greyhaven! Isn't it wonderful, " + a + "?");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("*An old crone approaches you...*");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("Old Crone: Why hello there. Would you like to do an old lady a favor?");
System.out.println("\t Press 1 to accept. Press 2 to deny.");
b = input.nextLine();
int c = Integer.parseInt(b);
if(c == 1){
System.out.println("Quest accepted!");
obj2.Quest1Accept();
}else{
System.out.println("Quest denied.");
obj3.Quest1Deny();
}
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("You leave the old woman.");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("Come on, " + a + ", I want to go to the store.");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("--You follow Charlie to the store.--");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("Ah yes here we are.");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("*You enter the store with Charlie.*");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("Shop owner: Hello! How may I help you today?");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("--You are currently browsing the shop. Shop items will be displayed below.--");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("Shop:");
System.out.println("Sword- \t 25 gold");
System.out.println("Boots- \t 40 gold");
System.out.println("Shield- 30 gold");
System.out.println("");
System.out.println("Press 1 to buy the sword. 2 for boots. 3 for shield.");
i = input.nextLine();
int j = Integer.parseInt(i);
if(j == 1){
}
if(j == 2){
}
if(j == 3){
}
}
}
Quest1Accept:
Code:
import java.util.Scanner;
public class Quest1Accept {
public void Quest1Accept(){
java.util.Scanner input = new java.util.Scanner(System.in);
String d;
mayor1 obj4 = new mayor1();
mayor2 obj5 = new mayor2();
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("Old Crone: Really? You'll help an old woman like me? Thank you.");
try{
Thread.sleep(3000);
}catch(InterruptedException e){
}
System.out.println("Old Crone: I'm sick of the crime rate in this city. Go to the Mayor and complain for me. Come back and tell me his answer.");
try{
Thread.sleep(5000);
}catch(InterruptedException e){
}
System.out.println("*You let out a sigh and leave for the mayor's office.*");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("The Mayor's office should be this way. Let's go.");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("*You and Charlie head for the Mayor's office.*");
try{
Thread.sleep(5000);
}catch(InterruptedException e){
}
System.out.println("There it is. The mayor's office. Let's head in.");
try{
Thread.sleep(3000);
}catch(InterruptedException e){
}
System.out.println("*You enter the office and see a grumpy mayor sitting at his desk.*");
try{
Thread.sleep(3000);
}catch(InterruptedException e){
}
System.out.println("Mayor Turnbomb: What do you want?");
System.out.println("\t Press 1 to tell the mayor about the quest and why you're here. Press 2 to leave.");
d = input.nextLine();
int f = Integer.parseInt(d);
if(f == 1){
obj4.mayor1();
}else{
obj5.mayor2();
}
try{
Thread.sleep(3000);
}catch(InterruptedException e){
}
System.out.println("*You leave the mayor's office.*");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("You return to the old woman.");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("You tell the woman what the mayor said and how you had to pay him.");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("Old Crone: Oh wonderful! Here. Take this as a reward.");
try{
Thread.sleep(1000);
}catch(InterruptedException e){
}
System.out.println("You receive 50 gold as a reward!");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("Quest Complete!");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("--You now have 80 gold.--");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
}
}
Quest1Deny:
Code:
import java.util.Scanner;
public class Quest1Deny {
public void Quest1Deny(){
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("Old Crone: Oh. Fine then. I will go about doing Old Crone things then.");
}
}
mayor1:
Code:
public class mayor1 {
public void mayor1(){
java.util.Scanner input = new java.util.Scanner(System.in);
String g;
int inv = 50;
System.out.println("*You walk up to the mayor.*");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("--Type what you want to say to the Mayor. Make it relevant to the quest.--");
g = input.nextLine();
System.out.println("You say to the mayor: " + g);
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("Mayor Turnbomb: A quest eh? Well. I suppose I could try to lower the crime rate.");
try{
Thread.sleep(2000);
}catch(InterruptedException e){
}
System.out.println("*You get excited*");
try{
Thread.sleep(3000);
}catch(InterruptedException e){
}
System.out.println("Mayor Turnbomb: But. For a price. 20 gold will do.");
try{
Thread.sleep(3000);
}catch(InterruptedException e){
}
System.out.println("--You currently have " + inv + "gold in your inventory.--");
int inv1 = inv - 20;
try{
Thread.sleep(3000);
}catch(InterruptedException e){
}
System.out.println("*You pay the mayor*");
try{
Thread.sleep(3000);
}catch(InterruptedException e){
}
System.out.println("--You currently have " + inv1 + "gold in your inventory.--");
}
}
mayor2:
Code:
public class mayor2 {
public void mayor2(){
System.out.println("*You decide not to talk to him because he looks grumpy.");
}
}
I will release the game here when it is finished (won't be for a while. It's going to be a big game.)
Yeah, it's mainly dialog because it's command line, but meh.
::blackhat::