
-----------------------------------
lord_dread
Sat Jan 29, 2011 10:15 pm

deaparately need help with dialog boxes and graphics.
-----------------------------------
all i need, is for a quick animation to pop up at the beginning of my game. for those of you who are wondering this game is completely different from the last one i tried getting help with here.

this wouldn't be a problem, but the game heavily uses dialog boxes, and i can't figure out how to use both in the same program. i know it's possible, i've done it before. i just can't find the program i did it in. please keep it as bare bones basic as possible (as in, grade 11 computer science basic)and please reply as soon as possible.please ignore the comments, as they are from previous programs. the method that needs to be added to the main program is the intro method and, while i've deleted anything pertaining to it here in the main program, i tried everything i could think of and none of it worked properly. thankyou, and please hurry, this is somewhat urgent. even if you don't know, could you at least say that, just reply.


here's my code:
main class:
/*kyle patton
05/11/2010
create a quiz with multiple difficulty levels.*/
//allows us to make option boxes
import java.applet.*;
import java.awt.*;
import javax.swing.*;
// The "Q" class.

public class RPSExpert

{
    
    public static void main (String[] args)
    { //declare images

        //java.awt.Graphics g;
        int repeat; //variable for choice of playing again
        int pHealth;
        int cHealth;
        //call the suplamentary class
        RPSExpertSup rps = new RPSExpertSup ();
        //call methods to read instructions
        rps.instructions ();
        //begin the main game loop
        do
        {
            rps.variableAssignment ();
            do
            {
                //get their answer
                rps.getInput ();
                //ceck their answer
                rps.comDecision ();

                rps.result ();
                pHealth = rps.getPHealth ();
                cHealth = rps.getCHealth ();
            }
            while ((pHealth > 0) && (cHealth > 0));
            if ((pHealth  0))
        {
            setup = (int) (Math.random () * 14) + 1; //x position of grass
            if ((setup >= 1) && (setup = 6) && (setup = 11) && (setup  0) && (cPaper > 0) && (cScissors > 0))
        {
            setup = (int) (Math.random () * 9) + 1; //x position of grass
            if ((setup >= 1) && (setup = 6) && (setup  0) && !(cPaper > 0) && (cScissors > 0))
        {
            setup = (int) (Math.random () * 9) + 1; //x position of grass
            if ((setup >= 1) && (setup = 6) && (setup  0) && (cPaper > 0) && !(cScissors > 0))
        {
            setup = (int) (Math.random () * 9) + 1; //x position of grass
            if ((setup >= 1) && (setup = 6) && (setup  0) && !(cPaper > 0) && (cScissors > 0))
        {
            cChoice = 3;
        }
        else if (!(cRock > 0) && (cPaper > 0) && !(cScissors > 0))
        {
            cChoice = 2;
        }
        else if ((cRock > 0) && !(cPaper > 0) && !(cScissors > 0))
        {
            cChoice = 1;
        }
    }


    public void result ()
    {
        if ((stringAnswer.equals ("ROCK")) && (pRock > 0)) //correct
        {
            pRock = pRock - 1;
            if (cChoice == 1)
            {
                tie ();
            }
            if (cChoice == 2)
            {
                lose ();
            }
            if (cChoice == 3)
            {
                win ();
            }
        }
        else if ((stringAnswer.equals ("PAPER")) && (pPaper > 0)) //correct
        {
            pPaper = pPaper - 1;
            if (cChoice == 2)
            {
                tie ();
            }
            if (cChoice == 3)
            {
                lose ();
            }
            if (cChoice == 1)
            {
                win ();
            }
        }
        else if ((stringAnswer.equals ("SCISSORS")) && (pScissors > 0)) //correct
        {
            pScissors = pScissors - 1;
            if (cChoice == 3)
            {
                tie ();
            }
            if (cChoice == 1)
            {
                lose ();
            }
            if (cChoice == 2)
            {
                win ();
            }
        }
        else if ((stringAnswer.equals ("ROCK")) && !(pRock > 0))  //correct
        {
            failure ();
        }
        else if ((stringAnswer.equals ("PAPER")) && !(pPaper > 0)) //correct
        {
            failure ();
        }
        else if ((stringAnswer.equals ("SCISSORS")) && !(pScissors > 0)) //correct
        {
            failure ();
        }
        else
        {
            JOptionPane.showMessageDialog (null, "Sorry, i don't know that substance", "wow, way to throw in the towel", JOptionPane.PLAIN_MESSAGE);
            pHealth = pHealth - 2;
        }

    }


    public void win ()
    {
        JOptionPane.showMessageDialog (null, "   You win!   ", "wait whaaaaat?", JOptionPane.PLAIN_MESSAGE);
        cHealth = cHealth - 2;
        cUsage ();
    }


    public void lose ()
    {
        JOptionPane.showMessageDialog (null, "         You lose!         ", "soon, victory shall be mine", JOptionPane.PLAIN_MESSAGE);
        pHealth = pHealth - 2;
        cUsage ();
    }


    public void tie ()
    {
        JOptionPane.showMessageDialog (null, "   It's a tie!   ", "is it wacky tie day already?", JOptionPane.PLAIN_MESSAGE);
        pHealth = pHealth - 1;
        cHealth = cHealth - 1;
        cUsage ();
    }


    public void failure ()
    {
        JOptionPane.showMessageDialog (null, "Your all out of that!", "yay! you used air! i win!", JOptionPane.PLAIN_MESSAGE);
        pHealth = pHealth - 2;
    }


    public void cUsage ()
    {
        if (cChoice == 1)
        {
            cRock = cRock - 1;
        }
        if (cChoice == 2)
        {
            cPaper = cPaper - 1;
        }
        if (cChoice == 3)
        {
            cScissors = cScissors - 1;
        }
    }


    public int getPHealth ()
    {
        //send score to main program
        return pHealth;
    }


    public int getCHealth ()
    {
        //send score to main program
        return cHealth;
    }


    public void intro (Graphics g)
    {
        rx = 160;
        ry = -150;
        px = 50;
        py = 200;
        sx = 375;
        sy = 200;
        //set the color
        g.setColor (Color.black);
        //code for drawing
        g.fillRect (0, 0, 400, 400);
        do
        {
            rock (g);
            rx = rx + 1;
            delay (10);
        }
        while (rx > 50);
        delay (500);
        do
        {
            paper (g);
            g.setColor (Color.black);
            g.fillRect (50, by, 75, 150);
            by = by - 1;
            delay (10);
        }
        while (by > 350);
        scissors (g);
    }


    public void rock (Graphics g)
    {
        g.setColor (new Color (175, 175, 175));
        g.fillOval (rx - 10, rx - 1, 80, 75);
        g.setColor (Color.black);
        g.fillOval (rx + 20, rx + 15, 30, 45);
        g.setColor (new Color (175, 175, 175));
        g.fillRect (rx, rx, 30, 150);
        g.fillRect (rx, rx + 75, 50, 25);
        g.fillRect (rx + 45, rx + 95, 15, 55);

    }


    public void paper (Graphics g)
    {
        g.setColor (new Color (255, 255, 255));
        g.fillOval (px - 10, px - 1, 80, 75);
        g.setColor (Color.black);
        g.fillOval (px + 20, px + 15, 30, 45);
        g.setColor (new Color (255, 255, 255));
        g.fillRect (px, px, 30, 150);
    }


    public void scissors (Graphics g)
    {
        g.setColor (new Color (255, 255, 255));
        g.drawLine (sx + 75, sy + 100, sx, sy + 150);
        delay (50);
        g.drawLine (sx + 75, sy + 100, sx, sy + 50);
        delay (50);
        g.drawLine (sx + 75, sy + 0, sx, sy + 50);
    }


    public static void delay (int ms)  //create pause method
    {
        try
        {
            Thread.sleep (ms);
        }
        catch (Exception e)
        {
            ;
        }
    } // delay
}

the method that needs to be added to the main program is the intro method and, while i've deleted anything pertaining to it here in the main program, i treid everything i could think of and none of it worked properly. thankyou, and please hurry, this is somewhat urgent.

-----------------------------------
Tony
Sat Jan 29, 2011 10:33 pm

Re: deaparately need help with dialog boxes and graphics.
-----------------------------------
all i need, is for a quick animation to pop up at the beginning of my game....
I would guess that the animation is independent from anything else, and should go before the "//begin the main game loop" part.

-----------------------------------
lord_dread
Sun Jan 30, 2011 6:02 am

RE:deaparately need help with dialog boxes and graphics.
-----------------------------------
yes, whenever i tried it, it was before utilising the instructions method and after calling the RPSExpertSup class. i'm going to try putting the animation in a separate class, then run the main game code from it.
