Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (526)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (593)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: I need some help with Java and scanning the screen for text. on: 2007-12-27 02:50:49
By "screen" yes, I mean the area you see.
2  Game Development / Newbie & Debugging Questions / Re: I need some help with Java and scanning the screen for text. on: 2007-12-26 20:29:12
No, just scanning the screen for text. For example, if I told the program to search for the word "the" it would tell me how many matches, where the first one is, etc.
3  Game Development / Newbie & Debugging Questions / I need some help with Java and scanning the screen for text. on: 2007-12-26 20:23:56
I have a question. Is there a way for me to search the screen for text, possibly store the text, copy, paste, and click on links on some kind of forums? I'm developing a program that will scan the screen for certain text and do things such as alert me to certain posts made and things like that. Thank you.
4  Java Game APIs & Engines / Java 3D / Re: I need a little help with Java3D. on: 2007-12-25 00:50:51
I can't really get any more specific. Well, they're not errors at all. They're warnings the compiler gives me before I even compile. I've installed Java3D, but Eclipse doesn't seem to be finding the files.
5  Game Development / Game Play & Game Design / Re: Way to handle multiples of the same item? on: 2007-12-24 20:28:06
Let's say Player A has some ammo and Player B has some ammo, and they both dropped their ammo on the ground. Then Player C comes a long and picks up 2 ammo objects. Wouldn't it get confusing whose ammo is whose? (If it were happening on a larger scale.) Or is it unimportant? Would it matter if the entire game contained thousands of ammo objects that all have the same name? (Programmatically. Not that they're all called "ammo," but that within the program they're all named "ammo.")
6  Java Game APIs & Engines / Java 3D / I need a little help with Java3D. on: 2007-12-24 20:11:18
I need some help using Java3D with Eclipse. I checked under the Tools Forum, but no one posted in it since late November. Anyway, how do I configure Eclipse to use Java3D? (By the way, I already hava the Java3D files.) I'm following Sun's Java3D tutorial, and when I paste in this code...

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.*;
import javax.vecmath.*;

public class HelloJava3Da extends Applet {
   public HelloJava3Da() {
   
      setLayout(new BorderLayout());
      GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
 
      Canvas3D canvas3D = new Canvas3D(config);
      add("Center", canvas3D);

      BranchGroup scene = createSceneGraph();
      scene.compile();

      // SimpleUniverse is a Convenience Utility class
      SimpleUniverse simpleU = new SimpleUniverse(canvas3D);

      // This moves the ViewPlatform back a bit so the
      // objects in the scene can be viewed.
      simpleU.getViewingPlatform().setNominalViewingTransform();

      simpleU.addBranchGraph(scene);
      } // end of HelloJava3Da (constructor)
   
   public BranchGroup createSceneGraph() {
      // Create the root of the branch graph
      BranchGroup objRoot = new BranchGroup();
      // Create a simple shape leaf node, add it to the scene graph.
      // ColorCube is a Convenience Utility class
      objRoot.addChild(new ColorCube(0.4));
      return objRoot;
      } // end of createSceneGraph method of HelloJava3Da
} // end of class HelloJava3Da


...I get a lot of "cannot be resolved" errors. Can anyone help? Thanks a lot! Grin
7  Game Development / Game Play & Game Design / Way to handle multiples of the same item? on: 2007-12-18 02:13:47
I have a question about this piece of code I wrote today.

1  
2  
3  
4  
5  
public void actionPerformed(ActionEvent evt) {
      Ammo ammo = new Ammo();
      Ammo.numAmmo++;
      label.setText("Number of ammo objects created: " + Integer.toString(Ammo.numAmmo));
   }


When I compile, and click a button any number of times, the number of ammo objects created goes up. How can this be when if I do something like this

1  
2  
Ammo ammo = new Ammo();
Ammo ammo = new Ammo();


the compiler gives me an error? If I were making a game that had ammo objects, how would I make multiples of the same object then? Where would they all live, in the program itself? Should I put them into a master array? Thanks.
8  Discussions / General Discussions / Re: Is Killer Game Programming in Java old or is it still a valuable resource? on: 2007-12-18 02:05:12
Thanks a lot! Grin
9  Discussions / General Discussions / Is Killer Game Programming in Java old or is it still a valuable resource? on: 2007-12-15 22:30:48
I was thinking of purchasing Killer Game Programming in Java, but I noticed it was published in 2005. Would the book still be a good purchase or should I wait until a more recent Java game programming book comes out?
10  Game Development / Newbie & Debugging Questions / Re: A better way to do this? (I'm sure there is.) on: 2007-12-15 07:42:44
Thanks. But how do I get random keys? I need to use a random number generator, but I can't because all of my keys are strings.
11  Game Development / Newbie & Debugging Questions / A better way to do this? (I'm sure there is.) on: 2007-12-14 04:33:39
Some of you may remember me from my thread about the "implements" keyword not working. I finally did get my program to work, but it's design isn't so good. I made a vocabulary tester to hone my Spanish skills (I guess it could work with any language) but I think I kind of designed it weird. The way it works is, there are two arrays, one containing Spanish words and the other containing the English equivalent. A random number generator stores an index in a variable arrayInt and then uses that index to pick a random word from the Spanish array. Once something is typed in the text field, the program checks to see if it exists in the English array. If it does, it gets it's index and compares it with the index of the Spanish word. If they match, it's counted as correct and the program continues.

The problem is, though, some Spanish words can mean different things. For example, alfrombra can mean carpet or rug. My program can only test for one of those because of the arrays. I know I probably went about this all wrong, but I just see it as an opportunity to improve. Grin Any help is greatly appreciated. Thanks! (Here's my code. Remember, I probably broke about a million code design rules, but I'm still learning. Smiley)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
import java.util.ArrayList;
import java.util.Random;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Test extends JFrame implements ActionListener {
   
   
   Random rand = new Random();
   
   ArrayList<String> dictionary = new ArrayList<String>();
   ArrayList<String> englishDict = new ArrayList<String>();
   
   int arrayInt;
   
   JLabel label1 = new JLabel();
   JTextField searchBar = new JTextField(25);
   
   public Test() {
      super("Tester");
     
      setSize(300, 100);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
      searchBar.addActionListener(this);
     
      FlowLayout flo = new FlowLayout();
      setLayout(flo);
     
      add(label1);
      add(searchBar);
     
      // Spanish array
      dictionary.add("casa");

                // English array
                englishDict("house");
     
      arrayInt = rand.nextInt(dictionary.size());
     
      label1.setText(dictionary.get(arrayInt));
     
      setVisible(true);
   }
   
   public void actionPerformed(ActionEvent e)
   {
     
      if (englishDict.indexOf(searchBar.getText()) == (dictionary.indexOf(dictionary.get(arrayInt)))) {
         JOptionPane.showMessageDialog(null, "Correct");
         searchBar.setText(null);
         arrayInt = rand.nextInt(dictionary.size());
         label1.setText(dictionary.get(arrayInt));
      }
     
      else {
         JOptionPane.showMessageDialog(null, "Incorrect, \"" + dictionary.get(arrayInt) + "\" means \"" + englishDict.get(arrayInt) + "\" in English.");
                searchBar.setText(null);
         
      }
     
   }
   
   public static void main(String[] args) {
      try {
         UIManager.setLookAndFeel(new
         com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
      }
      catch (Exception e) {
      }
         
      Test test = new Test();
     
   }
}
12  Game Development / Newbie & Debugging Questions / Re: My program won't let me use the "implements" keyword? on: 2007-12-13 21:58:16
Thanks, I got it now. But now I'm having trouble with my program skipping my if statement. I made my search button compare the text in the JLabel to the text in the JTextField, and it doesn't work. (My program will eventually be used to help build my Spanish vocabulary. The JLabel displays a Spanish word, and you have to type the English in the text box. If it's right, something will pop up and say "Correct!" I currently have it so that the JTextField says correct or incorrect, just because it's the concept that matters right now. I will also eventually make an array that has English in it, because right now I'm only comparing Spanish to Spanish. I'd like to just get the program working like normal before I get into adding words to the array.) Anyway, here's my program...

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
import java.util.ArrayList;
import java.util.Random;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Test extends JFrame implements ActionListener {
   Random rand = new Random();
   
   ArrayList<String> dictionary = new ArrayList<String>();
   
   JLabel label1 = new JLabel();
   JTextField searchBar = new JTextField(20);
   JButton correct = new JButton("Correct?");
   
   public Test() {
      super("Test");
      setSize(300, 300);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
      correct.addActionListener(this);
     
      FlowLayout flo = new FlowLayout();
      setLayout(flo);
     
      add(label1);
      add(searchBar);
      add(correct);
     
      dictionary.add("la casa");
     
      setVisible(true);
   }
   
        // check to see whether the Spanish word in the array matches the typed word.

   public void actionPerformed(ActionEvent e)
   {

      if (searchBar.getText() == label1.getText()) {
         searchBar.setText("Correct!");
      }
     
      else {
         searchBar.setText("Incorrect!");
      }
     
   }
   
   public static void main(String[] args) {
      Test test = new Test();
   }
}


Right now it judges everything as incorrect. What am I doing wrong? (Oh one more question. How come I can't add anything to my dictionary ArrayList right after I declare it? If I try to do "dictionary.add("example") I get an error. The only place I can add things to it is within my constructor method. Is this a scope issue?) Thanks.
13  Game Development / Newbie & Debugging Questions / Re: My program won't let me use the "implements" keyword? on: 2007-12-13 20:38:39
But it does implement actionPerformed. Doesn't it? Undecided
14  Game Development / Newbie & Debugging Questions / My program won't let me use the "implements" keyword? on: 2007-12-12 05:29:07
I wrote this program to tinker with event listeners and such.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Test extends JFrame {
   public Test() {
      super("Test");
      setSize(300, 300);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
      JTextField searchBar = new JTextField(20);
      searchBar.addActionListener(
            new ActionListener()
            {
               public void actionPerformed(ActionEvent e)
               {
                  // do something
               }
            });
      JButton search = new JButton("Search");
     
      FlowLayout flo = new FlowLayout();
      setLayout(flo);
     
      add(searchBar);
      add(search);
     
      setVisible(true);
   }
   
   public static void main(String[] args) {
      Test test = new Test();
   }
}


If I leave the program like that it's fine. But if I try to do "implements ActionListener" at the top, it gives me a warning. I'm using Eclipse, and it says, "The type Test must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent)" Why is it doing this? It won't even let me do "searchBar.addActionListener(this)" and then "public void actionPerformed(ActionEvent evt) {}" How come? Thanks for the help.
15  Game Development / Newbie & Debugging Questions / Re: Item management systems. on: 2007-11-30 03:57:29
So for my ItemDefinitions class, how would I define items, and how do I create the items if I don't have a class to instantiate? So if I wanted to store my items in a hash map, would I give them a name and a number? But how would I create multiple items with the same name?

Okay, let me rephrase all of my questions into one: How do MMORPGs define, create, and store items?
16  Game Development / Newbie & Debugging Questions / Item management systems. on: 2007-11-30 01:58:47
I have a few questions concerning item management systems.  First of all, if a player has an inventory to store certain items, where would you actually store the items in the program? Would you use some kind of array? And how would you name multiples of the same item, with a number after their name? So would you just use for loop to make, for example, item1, item2, item3, etc.? Almost done. Smiley How do you deal with multiple item generators? If I have two different parts of my game generating items, and the items are all the same except for a number after the name, how will I generate multiples of the same item without looping from zero? (two items named item1 would create some problems...) Do you just have some kind of master variable that you use in every item loop? And finally, if you use a loop to generate multiple items and each item name has a number after it, won't the item names become extremely long?

Thanks a lot, any help is appreciated.  I apologize for writing so much, I just had to ask these burning questions. Grin Thanks again!
17  Game Development / Newbie & Debugging Questions / Re: I need some help with finding text in a string and replacing it? on: 2007-11-26 05:03:54
Wow, thanks a lot, it makes much more sense now!  Grin One more question. I was planning on using this as a basic chat filter for a game. Is this the most efficient way to do it or are there better ones? Thanks.
18  Game Development / Newbie & Debugging Questions / What if I create a BufferedReader and exit the program without using close()? on: 2007-11-26 05:00:20
Will something bad happen if I create a BufferedReader and forget to use the close() method before exiting my program? Thanks a lot!
19  Game Development / Newbie & Debugging Questions / I need some help with finding text in a string and replacing it? on: 2007-11-23 21:18:31
I'm working on a program that needs to be able to search a string of text for certain words and then replace them with something else. I believe the best way (I'm probably wrong though Smiley) would be to compare the string to an ArrayList of words, and then replace the words with different ones. Does this sound like it would work? If it does how do I compare individual words inside the string to the words in the arrayList? Thanks.

I've got another quick question. When using the replace() method, how come I can't just do

1  
2  
object.text.replace("abc", "def");
System.out.println(object.text);


Whenever I do that it just gives me the same string that was stored in object.text. But when I do

1  
2  
object.text = object.text.replace("abc", "def");
System.out.println(object.text);


it works fine. Is that because the replace() method returns a string? Thanks.
20  Java Game APIs & Engines / Tools Discussion / Re: Why is NetBeans trying to act as a server? on: 2007-11-22 07:15:41
Oh okay, thanks.
21  Java Game APIs & Engines / Tools Discussion / Why is NetBeans trying to act as a server? on: 2007-11-22 05:12:51
I was just wondering why NetBeans tries to act as a server when I run my program. (It was just a simple "Hello World" program I wrote just to try out NetBeans a little.) I got a warning from my one firewall, which always happens when new programs try to act as servers, but then I got one from the Windows Firewall which almost never happens, so I kept blocking. Then, before NetBeans gave me a nasty error, it said it was trying to act as a server, and it said "Listening on port XXXX." (I forget which port.) Why is it doing this? Here is the code, it's just the default generated stuff. (I added the "Hi!" thing in there, though.)

package app1;

public class Main {
   
    public Main() {
    }
 
    public static void main(String[] args) {
       System.out.println("Hi!");
    }
   
}

Thanks. (A little side question. How come the class name isn't the name of my file, App1, what does that empty Main method do, and what does "package" do? Thanks.)
22  Game Development / Newbie & Debugging Questions / Re: I need a little help with event listeners in Swing? on: 2007-11-22 04:21:06
So would it be better to make a listener for every object or just one listener for every different type of object? (Say one for buttons, text boxes, etc.)
23  Game Development / Newbie & Debugging Questions / Re: I need a little help with event listeners in Swing? on: 2007-11-17 19:21:41
So would I use a bunch of if statements to check which textbox (for example) it was? What if I had a lot of textboxes?
24  Game Development / Newbie & Debugging Questions / I need a little help with event listeners in Swing? on: 2007-11-17 04:41:13
I don't really have any code, it's just a concept I need some help with.  Let's say I have two textboxes, and if you hit enter in one it does one thing and if you hit enter in the other it does something else.  If there's only one listener for text boxes (correct me if I'm wrong) how do you make each box do something different? Do you have to test which one triggered the event somehow? Thanks.
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (73 views)
2014-11-26 15:22:04

toopeicgaming1999 (62 views)
2014-11-26 15:20:36

toopeicgaming1999 (15 views)
2014-11-26 15:20:08

SHC (29 views)
2014-11-25 12:00:59

SHC (27 views)
2014-11-25 11:53:45

Norakomi (32 views)
2014-11-25 11:26:43

Gibbo3771 (27 views)
2014-11-24 19:59:16

trollwarrior1 (40 views)
2014-11-22 12:13:56

xFryIx (78 views)
2014-11-13 12:34:49

digdugdiggy (56 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!