dimanche 20 décembre 2015

Need help finishing rng game, JOptionPane, healthbar, and a few other things

Alright so heres what i have

    public static void main(String[] args) {
        int life = 100; //Your life
        int life2 = 100; //Enemy life
        Random chance = new Random();

    while (life >= 0 && life2 >= 0){
    int hitchance = chance.nextInt(100)+1; 

    if (hitchance >= 20 ){//Miss
        JOptionPane.showMessageDialog(null, "You have missed your opponent like a fool.\nYour Opponent has "+life2+" health remaining.");
    }
    if (hitchance >= 21 || hitchance <= 34){//Wiff
        int Wiff = chance.nextInt(10)+1;
        life = life-Wiff;
        JOptionPane.showMessageDialog(null, "You have stubbed your toe. Idiot.\nYou have "+life+" health remaining." +Wiff);
    }
    if (hitchance >= 35 || hitchance <= 74){//Regular Hit
        int regHit = chance.nextInt(20)+1;
        life2 = life2-regHit;
        JOptionPane.showMessageDialog(null, "You have hit your opponent for "+regHit+" damage!\nThey have "+life2+" health remaining.");
    }
    if (hitchance >= 74 || hitchance <= 90){//CritHit
        int critHit = chance.nextInt(40)+1;
        life2 = life2-critHit;
        JOptionPane.showMessageDialog(null, "You have dealt critical damage! "+critHit+"\nThey have "+life2+" health reamining.");
    }
    else {//Fatality.      
        JOptionPane.showMessageDialog(null, "Fatality!\nYou stabbed your opponent in the foot,\ndrug your knife throught"
                + "his belly,\nand impaled his head on your knife!");
        System.exit(0);
    }
    }

}
}

I need a healthbar added, A progress bar would do wonders, i need A JOptionPane to choose a type of character that is wanted to be, (Warrior, Assassin, Mage.) and lastly i need the cpu to hit you based on the same rng that is provided. Thanks guys!




Aucun commentaire:

Enregistrer un commentaire