mardi 27 janvier 2015

i am making an text based rpg game and my combat code while loop is not initating

this is my code the first part of the game runs where you can move around and when it gets to the while loop it just does not do anything did i do the while loop wrong or would it matter that the loop is inside a first loop



if(y==-1 && x==0){
System.out.println("You Entered A long Hallway With Lit Torches All The Way Down The Hall");
Combat = 1;
while(Combat==1);{
System.out.println("The "+enemy+" has attacked");
System.out.println("Press A To Attack");
try{
Attack=input.readLine();
}
catch (IOException ioe){
System.out.println("input error");
}
if(Attack.equals("A")){
Random randomGenerator=new Random();
Strike=randomGenerator.nextInt(damage1);
Strike+=5;
HP2-=Strike;
System.out.println("You Did "+Strike+" Damage");
System.out.println("The "+enemy+" Has "+HP2+" Life Left");
Strike2=randomGenerator.nextInt(damage);
Strike2+=5;
HP-=Strike2;
System.out.println("The "+enemy+" Did "+Strike2+" Damage");
System.out.println("You Have "+HP+" Life Left");
if(HP<=0){
System.out.println("You Died. Game Over.");
System.exit(0);
}
else if(HP2<=0){
Combat=0;
System.out.println("You Have Defeated The "+enemy+"! Congradulations!");
}
}
}
}


first loop segment



while(loop==0){
System.out.println(""+Name+" What Way Would You Like To Navigate Use WASD To Choose A Direction");
try{
Move=input.readLine();
}
// Movement Control Keys
catch (IOException ioe){
System.out.println("input error");
}
if(Move.equals("w")){ // Upward Movement
y+=1;
System.out.println("*****"+y);
}
else if(Move.equals("d")){ // Right Movement
x+=1;
System.out.println("*****"+x);
}
else if(Move.equals("s")){ // Downward Movement
y-=1;
System.out.println("*****"+y);
}
else{
x-=1; // Left Movement Key ("a")
System.out.println("*****"+x);
}
if(y==-1 && x==0){
System.out.println("You Entered A long Hallway With Lit Torches All The Way Down The Hall");
Combat = 1;
while(Combat==1);{

Aucun commentaire:

Enregistrer un commentaire