Random randomGenerator = new Random(); // randomGenerator can be anything, this is what you call it.
when you have put this is. it will have red lines underneath the Random. just go over and import random...
ok done tic.
make a int that you want to random.. for example
int randomGold;
int Gold
randomGold = 1+randomGenerator.nextInt(10);
Gold = randomGold;
now this will make a random number between 1 - 10.
simple.
this for fighting.
this is for character
int Level = 1;
int MaxHealth = Level*10;
int Health = MaxHealth;
int MinDamage = Level;
int MaxDamage = MaxHealth+Level-3;
this is for enemy
int EnemyLevel = Level;
int EnemyHealth = EnemyLevel*9;
int EnemyMinDamage = EnemyLevel;
int EnemyMaxDamage = MaxHealth+EnemyLevel-5;
now you have your ints.
Scanner input = new Scanner(System.in);
String FightCommand;
boolean Fightloop = false;
while (Fightloop == false) {
FightCommand = input.next();
if (FightCommand.equalsIgnoreCase("hit") {
int RandomHit;
RandomHit = MinDamage+randomGenerator.nextInt(MaxDamage);
EnemyHealth -= RandomHit;
if (EnemyHealth <=0) {
System.out.println("you have Killed Enemy")
Fightloop = true;
}
int RandomHit;
RandomHit = EnemyMinDamage+randomGenerator.nextInt(EnemyMaxDamage);
Health -= RandomHit;
if (Health <=0) {
System.out.println("you have died, Game over")
System.exit(0);
}
}
else if ( FightCommand.equalsIgnoreCase("flee"){
System.out.println("you Flee")
FightCommand = true
}
}
else {
System.out.println("unkown Command");
}
when you have put this is. it will have red lines underneath the Random. just go over and import random...
ok done tic.
make a int that you want to random.. for example
int randomGold;
int Gold
randomGold = 1+randomGenerator.nextInt(10);
Gold = randomGold;
now this will make a random number between 1 - 10.
simple.
this for fighting.
this is for character
int Level = 1;
int MaxHealth = Level*10;
int Health = MaxHealth;
int MinDamage = Level;
int MaxDamage = MaxHealth+Level-3;
this is for enemy
int EnemyLevel = Level;
int EnemyHealth = EnemyLevel*9;
int EnemyMinDamage = EnemyLevel;
int EnemyMaxDamage = MaxHealth+EnemyLevel-5;
now you have your ints.
Scanner input = new Scanner(System.in);
String FightCommand;
boolean Fightloop = false;
while (Fightloop == false) {
FightCommand = input.next();
if (FightCommand.equalsIgnoreCase("hit") {
int RandomHit;
RandomHit = MinDamage+randomGenerator.nextInt(MaxDamage);
EnemyHealth -= RandomHit;
if (EnemyHealth <=0) {
System.out.println("you have Killed Enemy")
Fightloop = true;
}
int RandomHit;
RandomHit = EnemyMinDamage+randomGenerator.nextInt(EnemyMaxDamage);
Health -= RandomHit;
if (Health <=0) {
System.out.println("you have died, Game over")
System.exit(0);
}
}
else if ( FightCommand.equalsIgnoreCase("flee"){
System.out.println("you Flee")
FightCommand = true
}
}
else {
System.out.println("unkown Command");
}
No comments:
Post a Comment