0

I've been rewriting a copy of the original Pokemon battle system in java.
hered my current code:

private void opTurn(){
//Todo: opponents random attack does random damage,
//misses, or causes a status effect
//p.pause(005);
wait(1)
Action.setText("Tiffayoniton attacked!");
curPl -= 10;
plCur.setText("" + curPl);
        
}
private void A1MouseClicked(java.awt.event.MouseEvent evt) {                                
        if (fight == true) {
            if (curOp == 0) {
                Action.setText("Tiffayoniton fainted");
            } else {
                Action.setText("Pikachu used Thundershock");
                curOp -= 10;
                opCurrent.setText("" + curOp);
                opTurn();
            }


        }

        if (item == true) {
            Action.setText("You threw a pokeball");

            //p.pause(2);
            //Action.setText("The pokeball missed");
        }

p.pause references this:

public static void pause(int s, int m, int n){
try{
Thread.sleep(500);
//Thread.currentThread().sleep((s * 1000) + m, n);
//Thread.sleep((s * 1000) + m, n);

}catch(InterruptedException e){

e.printStackTrace();

}

}

public static void pause(int s, int m){

pause(s, m, 0);

}

public static void pause(int s){

pause(s, 0, 0);

}

public static void pause(){

pause(1, 0, 0);

}

}

no matter what ive tried it always pauses everything first(without displaying anything in the else statement) then skips to the end of opTurn instead of displaying the stuff in the else statement,pausing, then displaying the remainder of opTurn.

is there any way of getting this to work properly?

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by NormR1
0

Try debugging your code to see what it is doing and why. Add lots of println() statements to follow logic flow and see how variables change.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.