Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How do i do a mouse over?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
JR




PostPosted: Mon Jun 07, 2004 8:11 am   Post subject: How do i do a mouse over?

i'm making who wants to be a millioner type game, and i was wondering how can i do a mouse over, i put the mouse over the right answer it highlights and i can press it.
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Tue Jun 08, 2004 11:03 pm   Post subject: (No subject)

Hacker Dan wrote:
that depondes on alot of things like:

what screen

what are you doing graficks or text in (console or window)

what kind of java u got (prue, ect)

and what APIs u using


same isues with that question, as your other one. Not hard to do if you using awt or swing and know some closione dection. But i can not guse on what you are using, ushey best to post some code to give us an idea.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
JR




PostPosted: Wed Jun 09, 2004 6:51 am   Post subject: (No subject)

its a text based heres the code...

code:


import java.awt.*;
import hsa.Console;
import java.io.*;
import java.math.*;



public class Final_Project
{
    static Console c;           // The output console
    static Question [] Questions; //The output questions
    static int qln;

    //array for the questions
    public Final_Project ()
    {
        qln = 38;
        //15 questions in the array
        Questions = new Question [15];
    }


    //reads the file with the questions.

    public static void ReadFile1 (String fileName)
    {
        String line, atext, aright; //text from the file, used to read and output the information.
        BufferedReader input;
        boolean bright;
        int pos;
        //file reader
        line = "";
        try
        {
            input = new BufferedReader (new FileReader (fileName));
            for (int v = 0 ; v < 15 ; v++)
            {
                line = input.readLine ();
                Questions [v] = new Question ();
                Questions [v].text = line;

                for (int b = 0 ; b < 4 ; b++)
                {
                    bright = false;
                    line = input.readLine ();
                    pos = line.indexOf (";");
                    atext = line.substring (0, pos);
                    aright = line.substring (pos + 1);
                    //checks for the answers
                    if (aright.indexOf ("t") == 0)
                    {
                        bright = true;
                    }
                    Questions [v].answers [b] = new Answer ();
                    Questions [v].answers [b].text = atext;
                    Questions [v].answers [b].right = bright;

                }
                line = input.readLine ();

            }
        } //if there is no file with that name
        catch (FileNotFoundException exs)
        {
            c.println ("Unable to find file");
        } //input output exceptions
        catch (IOException exss)
        {
            c.println ("Moo");
            c.println (exss.getMessage ());
        }
    }


    //adds a delay
    public static void delay ()
    {
        for (int counter = 1 ; counter < 99999 ; counter++)
        {
            double a = Math.PI * Math.PI;
        }
    }


    //openning screen
    public static void openning ()
    {
     int x=0;
     int y=0;
    for (int i=1;i<800;i++)
    {
 
c.setColor(Color.blue);
c.fillOval(0,0,x,500);
x+=1;
delay();

c.setColor(Color.black);
c.fillOval(0,0,y,500);
y+=1;
c.setColor(Color.red);
c.fillRect(0,0,x,500);
c.setColor(Color.white);
  Font font3 = new Font ("Ariel", Font.BOLD, 30);
        c.setFont (font3);
c.drawString("Who wants to be a millioner...",150,200);

 delay();
 c.clear();

}
 c.println("Press any key to continue");
 char ch;
 ch=c.getChar();
 Font font3 = new Font ("Ariel", Font.PLAIN, 15);
        c.setFont (font3);
        c.setColor(Color.black);
    }


    //draws the tables
    public static void draw ()
    {
        //game graphic
        // c.setColor(Color.yellow);
        //c.fillRect(20,20,400,260);
        c.setColor (Color.gray);
        c.fillRect (0, 0, 20, 424);

        c.fillRect (0, 405, 650, 20);

        c.fillRect (0, 0, 625, 20);

        c.fillRect (620, 0, 20, 424);

        c.fillRect (420, 0, 20, 424);

        c.fillRect (0, 280, 420, 20);

        c.fillRect (0, 350, 420, 10);
        c.setColor (Color.gray);
        c.fillRect (215, 280, 10, 400);

        //sets the font
        c.setColor (Color.black);
        Font font2 = new Font ("Times new roman", Font.PLAIN, 15);
        c.setFont (font2);
        //draws the money
        c.drawString ("$1000000", 490, 70);
        c.drawString ("$500000", 490, 90);
        c.drawString ("$250000", 490, 110);
        c.drawString ("$125000", 490, 130);
        c.drawString ("$64000", 490, 150);
        c.drawString ("$32000", 490, 170);
        c.drawString ("$16000", 490, 190);
        c.drawString ("$8000", 490, 210);
        c.drawString ("$4000", 490, 230);
        c.drawString ("$2000", 490, 250);
        c.drawString ("$1000", 490, 270);
        c.drawString ("$500", 490, 290);
        c.drawString ("$300", 490, 310);
        c.drawString ("$200", 490, 330);
        c.drawString ("$100", 490, 350);


    }


    //draws the question and the answers in their right boxes

    public static void showQestion (int index)
    {
        int rowCount, p1, p2, y;
        float rows;
        String row, Qtext;
        y = 100;
        Qtext = Questions [index].text;
        while (Qtext.length () > qln)
        {
            row = Qtext.substring (0, qln);
            c.drawString (row, 40, y);
            y += 20;
            Qtext = Qtext.substring (qln);
        }
        c.drawString (Qtext, 40, y);
        //draws the possible answers
        c.drawString (Questions [index].answers [0].text, 80, 325);
        c.drawString (Questions [index].answers [1].text, 290, 325);
        c.drawString (Questions [index].answers [2].text, 80, 390);
        c.drawString (Questions [index].answers [3].text, 290, 390);
    }


    //main program.
    public static void main (String [] args)
    {
        boolean exitLoop = false;
        int m = 0;
        int completed = 0;
        String finalMsg;
        c = new Console ();
        Final_Project fp = new Final_Project ();

        openning ();
        //menu
        int start, answerq;
        for (;;)
        {
            //start menu
            c.clear ();
            c.println ("******Welcome to who wants to be a millionare******");
             c.println ("Good luck playing");
            c.println ("1) New game");
            c.println ("2) Rules");
            c.println ("3) Exit");
            start = c.readInt ();
            if (start == 1)
            {
                c.clear ();
                //reads the file that contains the questions
                fp.ReadFile1 ("questions.txt");
                //will read the file until its empty
                while (!exitLoop)
                {
                    c.clear ();
                    fp.showQestion (m);
                    fp.draw ();

                    answerq = c.readInt ();
                    if (IsBetween (answerq, 1, 4))
                    {
                        Questions [m].userAnswer = answerq - 1;
                        exitLoop = !Questions [m].rightAnswer ();

                        if (Questions [m].rightAnswer ())
                        {

                            completed += 1;




                        }
                        m += 1;
                        if (m == 15)
                        {
                            exitLoop = true;
                        }

                    }
                }
                //if all 15 questions are done you get a special msg else theres no msg.
                finalMsg = "no msg";
                if (completed == 15)
                {
                    finalMsg = "Congratulations! You got it!\nYou won $1000000.";
                }
                //checks how many questions the user answered and if he has the unburned amount
                else if (IsBetween (completed, 0, 4))
                {
                    finalMsg = "You answered right " + completed + " questions.\nYou won $0.";
                }
                else if (IsBetween (completed, 5, 9))
                {
                    finalMsg = "You answered right " + completed + " questions.\nYou won$1000";
                }
                else if (IsBetween (completed, 10, 14))
                {
                    finalMsg = "You answered right " + completed + " questions.\nYou won$32000.";
                }
                c.clear ();
                c.println (finalMsg);


                break;
            }
            else if (start == 2)
            {
                //game instructions
                c.println ("There are 15 questions,each question has 1 possible answer\nThere are two unburnned amounts which are 1000 and 32000.\nHave fun playing");
                char readchar;
                readchar = c.getChar ();

            }

            else if (start == 3)
            {
                //Exit sequence
                c.println ("Thank you for playing who wants to be a millioner, press any key to exit");
                char chara;
                chara = c.getChar ();
                c.clear ();
                break;
            }
        }
    } // main method


    //check where the number is
    public static boolean IsBetween (int Num, int l, int m)
    {
        if (Num <= m && Num >= l)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
} // Final_Project class


Dan




PostPosted: Wed Jun 09, 2004 1:10 pm   Post subject: (No subject)

Sory but ready to progame is not true prue java, or at least it dose not have the standerd APIs. Since real java dose not have the HSA Console i can not run your code or know how the console works or how mouse could inrecat with it.

May be there is some one on the site that knows about Ready to Porgame (i realy should make a new fourm or a sub fourm for Ready to Porgame b/c in my option it dose not belong in java.)
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: