Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   Help. I got a problem in making Java games .. (http://www.programmingforums.org/showthread.php?t=14065)

bratsercom Sep 30th, 2007 12:01 AM

Help. I got a problem in making Java games ..
 
Help. I got a problem in making Java games ..
i dont know how to start it.. and what are laibraries. and other to call in making java Games..

could Someone Can give me An examPle Of Java Game program.

crawforddavid2006 Sep 30th, 2007 12:16 AM

ok, first of all do you know any java?

bratsercom Sep 30th, 2007 1:21 AM

Yes. i know java. were studieng now on using Joption pane..

crawforddavid2006 Sep 30th, 2007 1:30 AM

This might be useful for you.

http://javaboutique.internet.com/tut...e_Programming/

andro Sep 30th, 2007 1:41 AM

L to the O to the L

crawforddavid2006 Sep 30th, 2007 2:12 AM

what do you find so funny andro? I said it MIGHT be useful.

titaniumdecoy Sep 30th, 2007 2:47 AM

I think andro was addressing the OP, not you, david.

Brent Sep 30th, 2007 12:24 PM

Just a thought, you might want to learn a bit more Java and become more comfortable with the language before you get into game programming. Alot of times what will happen is people will begin to learn a new language, jump into something over their head, and get intimidated by it. Im not saying your not capable, just take it one step at a time.

crawforddavid2006 Sep 30th, 2007 1:51 PM

I have to agree with Brent. Become very comfortable with Java and as many of the GUI parts of it before you make an actual game.

bratsercom Oct 1st, 2007 4:47 AM

:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.Properties;
 
 
public class QuizGame extends JFrame implements ActionListener {
       
        Container MyBox = getContentPane();
       
        JPanel textareaPanel = new JPanel();
        JPanel buttonsPanel = new JPanel();
       
        JTextArea textarea = new JTextArea(15,30);
        JScrollPane scroll = new JScrollPane( textarea);
       
        JButton Answer1 = new JButton( "Answer 1");
        JButton Answer2 = new JButton( "Answer 2");
        JButton Answer3        = new JButton( "Answer 3");
        JButton Answer4 = new JButton( "Answer 4");
        JButton NextQuestion = new JButton( "Next Question");
        JButton Exit = new JButton ( "Exit");
        String AppExit = "";
        String question = "";
        String answer1 = "";
        String answer2 = "";
        String answer3 = "";
        String answer4 = "";
        String correctAnswer = "";
        String userAnswer = "";
 
       
        public QuizGame()
        {
                super ("The Quiz");
                setSize(400,500);
                JOptionPane.showMessageDialog(null, "Welcome to \"The Quiz\" PRE-Alpha");
        }
       
        public void GUI()
        {
                MyBox.setLayout(new BorderLayout());
                MyBox.setBackground(Color.black);
                MyBox.add(textareaPanel, BorderLayout.NORTH);
                MyBox.add(buttonsPanel, BorderLayout.CENTER);
       
                buttonsPanel.setLayout(new GridLayout(2,3));
               
                textareaPanel.add(textarea);
               
                textarea.setEditable(false);
               
                buttonsPanel.setBackground(Color.black);
                buttonsPanel.add(Answer1, BorderLayout.CENTER );
                buttonsPanel.add(Answer3, BorderLayout.CENTER);
                buttonsPanel.add(NextQuestion, BorderLayout.WEST);
                buttonsPanel.add(Answer2, BorderLayout.WEST);
                buttonsPanel.add(Answer4, BorderLayout.WEST);
                buttonsPanel.add(Exit, BorderLayout.EAST);
               
                Answer1.addActionListener(this);
                Answer2.addActionListener(this);
                Answer3.addActionListener(this);
                Answer4.addActionListener(this);
                NextQuestion.addActionListener(this);
                Exit.addActionListener(this);
        }
       
        public void Properties()
        {
       
                Properties questionProperties = new Properties();
                FileReader questionIn = new FileReader(new File("P:\\Quiz\\QuizGame\\question.txt"));
                questionProperties.read(questionIn);
 

                String question = questionProperties.getProperty("question.txt");
                String answer1 = questionProperties.getProperty("answer.1");
                String answer2 = questionProperties.getProperty("answer.2");
                String answer3 = questionProperties.getProperty("answer.3");
                String answer4 = questionProperties.getProperty("answer.4");
                String correctAnswer = questionProperties.getProperty("answer.correct");
               
                textarea.append(question+"\n\n"+answer1+"\n"+answer2+"\n"+answer3+"\n"+answer4);
        }
       
       
        public void actionPerformed(ActionEvent event)
        {
                if ( event.getActionCommand().equals("Answer 1"))
                {
                        userAnswer = answer1;
                        if (userAnswer.equals(correctAnswer))
                        {
                                JOptionPane.showMessageDialog(null, "Correct!");
                        }
                        else
                        {
                                JOptionPane.showMessageDialog(null, "You're wrong!");
                        }
                }
                if ( event.getActionCommand().equals("Answer 2"))
                {
                        userAnswer = answer2;
                        if (userAnswer.equals(correctAnswer))
                        {
                                JOptionPane.showMessageDialog(null, "Correct!");
                        }
                        else
                        {
                                JOptionPane.showMessageDialog(null, "You're wrong!");
                        }
                }
                if ( event.getActionCommand().equals("Answer 3"))
                {
                        userAnswer = answer3;
                        if (userAnswer.equals(correctAnswer))
                        {
                                JOptionPane.showMessageDialog(null, "Correct!");
                        }
                        else
                        {
                                JOptionPane.showMessageDialog(null, "You're wrong!");
                        }
                }
                if ( event.getActionCommand().equals("Answer 4"))
                {
                        userAnswer = answer4;
                        if (userAnswer.equals(correctAnswer))
                        {
                                JOptionPane.showMessageDialog(null, "Correct!");
                        }
                        else
                        {
                                JOptionPane.showMessageDialog(null, "You're wrong!");
                        }
                }
               
                if ( event.getActionCommand().equals("Exit"))
                {
                        JOptionPane.showMessageDialog(null, "Thank you for using\"The Quiz\"");
                        System.exit(0);
                }
               
                if ( event.getActionCommand().equals("Next Question"))
                {
                        JOptionPane.showMessageDialog(null, "Still Working on it!");
                }
        }
 
        public void init()
        {
                  //
        }
       
        public static void main(String args[])
        {               
                QuizGame object = new QuizGame();
                object.GUI();
                object.Properties();
                object.setVisible(true);
               
        }
}


Quote:

--------------------Configuration: <Default>--------------------
C:\QuizGame.java:75: cannot resolve symbol
symbol : method read (java.io.FileReader)
location: class java.util.Properties
questionProperties.read(questionIn);
^
1 error

Process completed.
i got this one but it has a problem \..

someone help me please


All times are GMT -5. The time now is 3:53 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC