Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (404)
games submitted by our members
Games in WIP (289)
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 / Networking & Multiplayer / Re: Networking & Multiplayer - Resources on: 2012-04-01 03:29:56
Where are all the resources?
2  Game Development / Newbie & Debugging Questions / Re: me and my noobish brother are having problems with Scanners on: 2012-03-07 03:26:34
First of all, thanks to all that replied SO FAST!!! and second, me and my VERY noobish brother totally just LOL-ed ALL over the floor Cheesy it was grand! Thanks for the java-lin exp. Cheesy and IT WORKS!!!!! WWOOOOOTTTT!!!
3  Game Development / Newbie & Debugging Questions / me and my noobish brother are having problems with Scanners on: 2012-03-07 03:07:05
The problem is, every time we type "no", we have to type it twice??
We don't understand why? Please help.... Smiley

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
package dandd.aanda;

import java.util.Scanner;

public class TestPrintf {
   public static void main(String[] args)  {
     
      String yes = "yes";
      String no = "no";
     
      System.out.println("type yes or no");
     
      Scanner input = new Scanner(System.in);
     
      if (input.nextLine().equals(yes)) {
         System.out.println("Follow me then boooyyyoo!!!!");
      } else if (input.nextLine().equals(no)) {
         System.out.println("Alright then laddy, you just going to sit on the porch all day and crrry then?");
      } else {
         System.out.println("that didn't help me, yes or no?");
      }
     
   }
4  Game Development / Newbie & Debugging Questions / Re: JFrame problems "setLayout (new FlowLayout);" on: 2012-02-28 16:09:45
wow.... I am a total noob Tongue haha

thank you a ton!!
5  Game Development / Newbie & Debugging Questions / JFrame problems "setLayout (new FlowLayout);" on: 2012-02-28 15:22:42
Hello,

I am going through a tutorial on JFrame's and I ran into a problem...
The tutorial was made in 2009 so... I'm thinking maybe something has changed sense then?
This code doesn't give an error for the guy giving the tutorial, unless I am missing something.

the error is in "new FlowLayout"
It can't make a new FlowLayout object... But I imported it... Tongue huh


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
package boston.tutorial;

import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.FlowLayout;

public class tuna51 extends JFrame{
   
   private JLabel item1;
   
   public tuna51() {
      super ("The title bar");
      setLayout (new FlowLayout);
     
      item1 = new JLabel("This is a sentance.");
      item1.setToolTipText("This is going to show up on hover.");
      add(item1);
   }
   
}


thanks Smiley
6  Game Development / Newbie & Debugging Questions / Re: Array List issues :P (advise is welcome) I'm new to java.... on: 2012-02-22 17:46:02
huh...
when i do that it gives me this

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
Exception in thread "main" java.lang.StackOverflowError
   at java.util.ArrayList.contains(ArrayList.java:199)
   at org.watersedge.Player.start(Player.java:28)
   at org.watersedge.Player.reStart(Player.java:46)
   at org.watersedge.Player.start(Player.java:42)
   at org.watersedge.Player.reStart(Player.java:46)
   at org.watersedge.Player.start(Player.java:42)
   at org.watersedge.Player.reStart(Player.java:46)
   at org.watersedge.Player.start(Player.java:42)
   at org.watersedge.Player.reStart(Player.java:46)
   at org.watersedge.Player.start(Player.java:42)
   at org.watersedge.Player.reStart(Player.java:46)
   at org.watersedge.Player.start(Player.java:42)
   at org.watersedge.Player.reStart(Player.java:46)
       // this goes on for a long time......


I think the problem is that every time the start() method runs again,
after I assign what the input variable is... It just keeps on looping and
never stops because input = "take book" every time afterwards....
I have tried assigning input to null, input = null, just before the
reStart() method... But it didn't seem to do anything....
7  Game Development / Newbie & Debugging Questions / Array List issues :P (advise is welcome) I'm new to java.... on: 2012-02-22 04:04:25
Hello,

I am having problems with a method I'm working on to handle adding and removing objects from two array lists.

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  
public class Player {
   
   public static ArrayList<String> inventory = new ArrayList<String>();
   UserInput input = new UserInput();
   
   public void start() {
     
      if (UserInput.getInput("").equalsIgnoreCase("take book")) {
         if (Room1.room1.contains("book")) {
            inventory.add("book");
            Room1.room1.remove("book");
            getStatus();
            Room1.getStatus();
         }
      } else if (UserInput.getInput("").equalsIgnoreCase("drop book")) {
         if (inventory.contains("book")) {
            inventory.remove("book");
            Room1.room1.add("book");
            getStatus();
            Room1.getStatus();
         }
      } else if (UserInput.getInput("").equalsIgnoreCase("take paper")) {
         if (Room1.room1.contains("paper")) {
            inventory.add("paper");
            Room1.room1.remove("paper");
            getStatus();
            Room1.getStatus();
         }
      } else if (UserInput.getInput("").equalsIgnoreCase("drop paper")) {
         if (inventory.contains("paper")) {
            inventory.remove("paper");
            Room1.room1.add("paper");
            getStatus();
            Room1.getStatus();
         }
      }
      reStart();
   }


It (sorta) does what I want it to do....
But for for some reason I have to type for example "take book" like four times before it actually prints the outcome.
And for each input it seems to be random as to how many times I have to type it in before it actually prints it.

Just to clarify so you can help me better...
the reStart() method just calls the start() method again.
The getStatus() methods from both the Room1 class and Player class just print their equivalent Array list.

This is the GetInput() method...
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
public static String getInput(String prompt) {
      BufferedReader stdin = new BufferedReader(
            new InputStreamReader(System.in));
     
      System.out.print(prompt);
      System.out.flush();
     
      try {
         return stdin.readLine();
      } catch (Exception e) {
         return "Error; " + e.getMessage();
      }
   }


If there is more info you need to help, let me know....

Also, If you have any suggestion on a better idea on how I should do this PLEASE let me know Smiley
I am very new to java coding and I am learning, this is a text adventure I am working on....

Thank you!
Pages: [1]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (45 views)
2013-05-17 21:29:12

alaslipknot (54 views)
2013-05-16 21:24:48

gouessej (83 views)
2013-05-16 00:53:38

gouessej (82 views)
2013-05-16 00:17:58

theagentd (91 views)
2013-05-15 15:01:13

theagentd (84 views)
2013-05-15 15:00:54

StreetDoggy (128 views)
2013-05-14 15:56:26

kutucuk (150 views)
2013-05-12 17:10:36

kutucuk (150 views)
2013-05-12 15:36:09

UnluckyDevil (160 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.23 seconds with 21 queries.