Post by Admin on Jan 5, 2016 13:46:11 GMT
Game Code 1
Angels vs Demons
Angels vs Demons
Below is the first one code. Copy paste the code into BlueJ.
If you'd like some background noise, go back to the previous page and pick out some music to listen to! Or choose a different game!
Angels vs Demons.
If you'd like some background noise, go back to the previous page and pick out some music to listen to! Or choose a different game!
Angels vs Demons.
/**
* Emma Donahue
* F Period
*/
import javax.swing.JOptionPane;
public class Project1 {
/**
*The following are static variable, which can be found almost >Anywhere< in codes.
*/
static boolean quit = false;
static String place = "start";
/**
*This method is used so you don’t have to write JOptionpane over and over again.
*/
public static String q(String m) {
String s = JOptionPane.showInputDialog(m);
return s;
}
/**
* showMessageDialog is made shorter by using this method.
*/
public static void m(String s) {
JOptionPane.showMessageDialog(null, s);
}
public static void main(String [] args) {
while(!quit) {
if (place.equals("start")) {
start();
} else if (place.equals("Angels")) {
Angels();
} else if (place.equals("Demons")) {
Demons();
} else if (place.equals("ghost")) {
m("You shall forever remain a lost ghost.");
quit = true;
} else if (place.equals("win")) {
m("You’ve successfully made it into the world you’ve chosen. Good Job, hopefully you chose wisely.");
quit = true;
}
}
}
/**
*Here is where the game begins. Choose wisely between your options and try to get the the end. Will you make it?
*Using a String for more than one line of code is seen here.
*/
public static void start() {
String choice = q("You have just entered the world of the Supernatural.\n"+
"You’re standing on the threshold between Hell its self and Heaven, then you’re given a choice.\n"+
"Who do you side with /a/ngels or the /d/emons? Asked the Gatekeeper.");
if (choice.equals("a")) {
place = "Angels";
} else if (choice.equals("d")) {
place = "Demons";
}
}
/**
* This is where you'd end up if you chose a for Angels.
* You must answer it correctly or a punishment is sure to come.
* >> Here if you guess correctly you'll either move on and live in heaven.
* >> If you do not guess correctly the code will send you out of the game and you'll have to start over.
*/
public static void Angels() {
String choice = q("You look around and see that everything is bright, happy and feels safe. You’re in heaven.\n"+
"There’s a light mist surrounding the area on which you stand upon and you’re then greeted by an angelic voice. \nIt asks you a Question:\n"+
"This is the device in which Angels use in a battle. It’s sharp, though it is not called a knife. It’s an Angel…?");
if (choice.equals("Angel Blade")) {
m("You’ve p??ed the test.\n"+
"You’re now able to roam around heaven in peace and go where you please.\n"+
"Good Job. You’ve chosen wisely.");
place = "win";
} else {
m("You’re Banished from Heaven.");
place = "ghost";
}
}
/**
* Here is were you'll cross paths with a demon. Fight it or run, you pick but either choice will effect the outcome.
* >>If you choose to fight (C) you will have 30% chance of loosing...
* >>If you loose the code will end and you'll have to restart...
* >>If you win the code will end...
* >>If you choose not to fight the code will send you back to the Gatekeeper and you'll have to restart.
*/
public static void Demons() {
String choice = q("It is dark and smells like death.\nA terrifying creature appears and it seems to challenge you to a duel...\n"+
"Do you wish to accept it?\n[C]ome @ m3! or [lol] no m8.");
if (choice.equals("C")) {
double fight = Math.random();
if (fight > 0.4) {
m("You realize you’re not strong enough to take on the creature so you run for your life.");
place = "ghost";
} else {
m("You were able to fight off the demon.\ngr8.");
place = "win";
}
} else if (choice.equals("lol")) {
m("You’re banished from the underworld.\nThen you end up falling into a never ending abyss...lol bye.");
place = "start";
}
}
}
/**
* This is the end of the code! Congrats! You either made it or lost either way this is the end. :3
*/
* Emma Donahue
* F Period
*/
import javax.swing.JOptionPane;
public class Project1 {
/**
*The following are static variable, which can be found almost >Anywhere< in codes.
*/
static boolean quit = false;
static String place = "start";
/**
*This method is used so you don’t have to write JOptionpane over and over again.
*/
public static String q(String m) {
String s = JOptionPane.showInputDialog(m);
return s;
}
/**
* showMessageDialog is made shorter by using this method.
*/
public static void m(String s) {
JOptionPane.showMessageDialog(null, s);
}
public static void main(String [] args) {
while(!quit) {
if (place.equals("start")) {
start();
} else if (place.equals("Angels")) {
Angels();
} else if (place.equals("Demons")) {
Demons();
} else if (place.equals("ghost")) {
m("You shall forever remain a lost ghost.");
quit = true;
} else if (place.equals("win")) {
m("You’ve successfully made it into the world you’ve chosen. Good Job, hopefully you chose wisely.");
quit = true;
}
}
}
/**
*Here is where the game begins. Choose wisely between your options and try to get the the end. Will you make it?
*Using a String for more than one line of code is seen here.
*/
public static void start() {
String choice = q("You have just entered the world of the Supernatural.\n"+
"You’re standing on the threshold between Hell its self and Heaven, then you’re given a choice.\n"+
"Who do you side with /a/ngels or the /d/emons? Asked the Gatekeeper.");
if (choice.equals("a")) {
place = "Angels";
} else if (choice.equals("d")) {
place = "Demons";
}
}
/**
* This is where you'd end up if you chose a for Angels.
* You must answer it correctly or a punishment is sure to come.
* >> Here if you guess correctly you'll either move on and live in heaven.
* >> If you do not guess correctly the code will send you out of the game and you'll have to start over.
*/
public static void Angels() {
String choice = q("You look around and see that everything is bright, happy and feels safe. You’re in heaven.\n"+
"There’s a light mist surrounding the area on which you stand upon and you’re then greeted by an angelic voice. \nIt asks you a Question:\n"+
"This is the device in which Angels use in a battle. It’s sharp, though it is not called a knife. It’s an Angel…?");
if (choice.equals("Angel Blade")) {
m("You’ve p??ed the test.\n"+
"You’re now able to roam around heaven in peace and go where you please.\n"+
"Good Job. You’ve chosen wisely.");
place = "win";
} else {
m("You’re Banished from Heaven.");
place = "ghost";
}
}
/**
* Here is were you'll cross paths with a demon. Fight it or run, you pick but either choice will effect the outcome.
* >>If you choose to fight (C) you will have 30% chance of loosing...
* >>If you loose the code will end and you'll have to restart...
* >>If you win the code will end...
* >>If you choose not to fight the code will send you back to the Gatekeeper and you'll have to restart.
*/
public static void Demons() {
String choice = q("It is dark and smells like death.\nA terrifying creature appears and it seems to challenge you to a duel...\n"+
"Do you wish to accept it?\n[C]ome @ m3! or [lol] no m8.");
if (choice.equals("C")) {
double fight = Math.random();
if (fight > 0.4) {
m("You realize you’re not strong enough to take on the creature so you run for your life.");
place = "ghost";
} else {
m("You were able to fight off the demon.\ngr8.");
place = "win";
}
} else if (choice.equals("lol")) {
m("You’re banished from the underworld.\nThen you end up falling into a never ending abyss...lol bye.");
place = "start";
}
}
}
/**
* This is the end of the code! Congrats! You either made it or lost either way this is the end. :3
*/
DO NOT COPY PASTE THIS PART.
There is small type down here that keeps making it's way into the code and messes it up.