Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (117)
games submitted by our members
Games in WIP (563)
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: Stop old Thread when a new one will be initialized on: 2009-06-20 13:04:24
Thanks you guys, it works Cheesy

I store the JFrame and the JLabel in a static variable and "hide -> update -> show" the JFrame whitout create a new one.

next step: semi transparent JFrame Cheesy
2  Game Development / Newbie & Debugging Questions / Re: Stop old Thread when a new one will be initialized on: 2009-06-18 19:31:56
I implemented like you postet it.

A small problem the
1  
2  
3  
4  
if(display_window) {
    if(this.displayInfo != null && this.displayInfo.isAlive()) {
        this.displayInfo.getFrame().dispose();
    }

wont be executed, as well there is another frame/instance...
I cant see the problem on my code!

I attached my complete code Wink
with ./b I compile it and with ./r I run it, its linux only (the Jinput plugin is only included with linux sources...) Wink

EDIT:/
my ass, why I cant upload a zip file?
You can find my code here -> http://www.rrelmy.ch/code.zip
3  Game Development / Newbie & Debugging Questions / Stop old Thread when a new one will be initialized on: 2009-06-17 21:20:15
Hi

I got several Threads:
one to Listen the Joystick input and fire an event when a significant change was detected, works very good with jinput.
the other one is a swing jFrame shown for several seconds when a event was fired.

The basic was my app does is listen to the joystick -> execute a action and displays a JFrame what happend.

I dont wanna that 2 JFrames show up at the same time, when a new JFrame should be opened the older one should dispose before the new one shows up.

1  
2  
3  
4  
5  
6  
7  
...
while(queue.getNextEvent(event)) {
      StringBuffer buffer = new StringBuffer();
      Component comp = event.getComponent();
      JoyStickAction.action(comp, event.getValue());
}
...

the joystick listener executing the action class

1  
2  
3  
4  
5  
...
if(display_window) {
            new DisplayInfo("title", window_text, 250, 50, 1000).start();
}
...

at the end of the action class

DisplayInfo is the class that opens the JFrame I wanna close when already a instance was createt

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  
import javax.swing.*;
import java.awt.*;
public class DisplayInfo extends Thread {
    //title and text
   String title;
    String text;

    //size in pixels
   int width = 400;
    int height = 100;

    //time to display in ms
   int time = 3000;

    //class infos
   static int instances = 0;
    static DisplayInfo instance;

    public DisplayInfo(String title, String text, int width, int height, int time) {
        if(instances>0) {
            instance.stopInstance();
        }
        ++instances;
        instance = this;
        this.title = title;
        this.text = text;
        this.width = width;
        this.height = height;
        this.time = time;
    }

    public void run() {
        //Create and set up the window.
       JFrame frame = new JFrame(title);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setUndecorated(true); //removes the borders

        //add text to the frame
       JLabel label = new JLabel(instances+" - "+text, JLabel.CENTER);
        label.setForeground(new Color(0xBB, 0xBB, 0xBB));
        frame.getContentPane().add(label);

        //set size
       frame.setSize(width, height);

        //get screen size
       Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension screenSize = toolkit.getScreenSize();

        //Calculate the frame location
       int x = (screenSize.width - frame.getWidth()) / 2;
        int y = ((screenSize.height - frame.getHeight()) / 3) * 2;

        //color
       frame.getContentPane().setBackground(new Color(0x33, 0x33, 0x33));

        //Display the window.
       frame.setLocation(x ,y);
        frame.setVisible(true);

        //wait
       try {
            Thread.currentThread().sleep(time);
        } catch(InterruptedException ie) { }
        //close
       frame.dispose();
    }

    public void stopInstance() {
        --instances;
        this.stop();
    }
}

I already tested something with instance counting and trying to close the old one but that wont work.
Probably the the thread wont be passed by reference to "instance"?
It's the way I would do it in PHP Smiley

How could I get it work?

Hopefully you understand what I wanna say...
4  Java Game APIs & Engines / JInput / Linux and the XBox 360 Wireless Controller on: 2009-06-13 14:47:01
I got a XBox 360 Ctrontroller for Windows(R)

The Jinput ControllerReadTest gives me 4 Windows with button informations and one empty.
But only one window has the right values when I press Buttons the other 3 windows remain on the default values.

Same thing on the TextTest
First I got some errors
Quote
Failed to open device (/dev/input/event2): Failed to open device /dev/input/event2 (13)
Failed to open device (/dev/input/event3): Failed to open device /dev/input/event3 (13)
Failed to open device (/dev/input/event4): Failed to open device /dev/input/event4 (13)
Failed to open device (/dev/input/event1): Failed to open device /dev/input/event1 (13)
Failed to open device (/dev/input/event0): Failed to open device /dev/input/event0 (13)
Failed to open device (/dev/input/js3): Failed to get button map (22)
Failed to open device (/dev/input/js2): Failed to get button map (22)
Failed to open device (/dev/input/js1): Failed to get button map (22)
Failed to open device (/dev/input/js0): Failed to get button map (22)
My connected an working Controller is under /dev/input/js0

Then
Quote
Linux plugin claims to have found 4 controllers
Xbox 360 Wireless Receiver
Type: Gamepad
Component Count: 21
Xbox 360 Wireless Receiver
Type: Gamepad
Component Count: 21
Xbox 360 Wireless Receiver
Type: Gamepad
Component Count: 21
Xbox 360 Wireless Receiver
Type: Gamepad
Component Count: 21
I got the same when I only put the USB Receiver on my PC.

So, how can I check if one or which Controller is up and running?

I'm running Debian Lenny 64Bit with the latest kernel (2.6.30) which is compiled with full joystick and xbox gamepad support/drivers.

Edit:
Like claimed in a other topic no rumbler were detected.
5  Game Development / Newbie & Debugging Questions / Re: loading library from jar, classpath... on: 2009-06-13 13:39:43
thanks

It's working now

1  
java -Djava.library.path=. -cp .:jinput.jar test


Last question the "libjinput-linux64.so" file have to be in the library path, thats right?

6  Game Development / Newbie & Debugging Questions / Re: loading library from jar, classpath... on: 2009-06-13 13:13:20
I thought java has a autoload functionality like with other classes Cheesy
Know I understand the hole thing, thank you.

unfortunately I got this Errors while executing
Quote
Loading: net.java.games.input.LinuxEnvironmentPlugin
Failed to load library: no jinput-linux64 in java.library.path
java.lang.UnsatisfiedLinkError: no jinput-linux64 in java.library.path
   at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1698)
   at java.lang.Runtime.loadLibrary0(Runtime.java:840)
   at java.lang.System.loadLibrary(System.java:1047)
   at net.java.games.input.LinuxEnvironmentPlugin$1.run(LinuxEnvironmentPlugin.java:66)
   at java.security.AccessController.doPrivileged(Native Method)
   at net.java.games.input.LinuxEnvironmentPlugin.loadLibrary(LinuxEnvironmentPlugin.java:58)
   at net.java.games.input.LinuxEnvironmentPlugin.<clinit>(LinuxEnvironmentPlugin.java:101)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:186)
   at net.java.games.input.DefaultControllerEnvironment.getControllers(DefaultControllerEnvironment.java:156)
   at test.main(test.java:6)
net.java.games.input.LinuxEnvironmentPlugin is not supported

Is there a Linux 64Bit Plugin or a workaround for this error?

Tried the Nightly build, same error
7  Game Development / Newbie & Debugging Questions / Re: loading library from jar, classpath... on: 2009-06-13 13:02:13
hmm, no

got no imports at the moment Cheesy

which imports I should have?
8  Game Development / Newbie & Debugging Questions / Re: loading library from jar, classpath... on: 2009-06-13 11:45:08
no Sad

1  
javac -cp .:jinput.jar *.java

same errors

Quote
test.java:5: cannot find symbol
symbol  : class Controller
location: class test
        Controller[] ca = ControllerEnvironment.getDefaultEnvironment().getControllers();
        ^
test.java:5: cannot find symbol
symbol  : variable ControllerEnvironment
location: class test
        Controller[] ca = ControllerEnvironment.getDefaultEnvironment().getControllers();
                          ^
test.java:14: cannot find symbol
symbol  : class Component
location: class test
            Component[] components = ca.getComponents();
            ^
3 errors

I downloaded the latest JInput Binaries and put them in the directory
Quote
jinput-dx8_64.dll  jinput-dx8.dll  jinput.jar  jinput-raw_64.dll  jinput-raw.dll  jinput-test.jar  jinput-wintab.dll  libjinput-linux64.so  libjinput-linux.so  libjinput-osx.jnilib  test.java
test.java is my class
9  Games Center / Archived Projects / Re: Lavirinto3d on: 2009-06-12 20:12:01
nice, like kula world for Playstation 1 Cheesy
10  Game Development / Newbie & Debugging Questions / loading library from jar, classpath... on: 2009-06-12 19:32:46
Hi

I'm not new to programming but some things in java I don't understand until know.

I'm programming at Linux Debian Lenny 64Bit.

The first thing: I got the JInput class as .jar file
I createt a class with the code from http://www.java-gaming.org/topics/getting-started-with-jinput/16866/view.html
when i compile the class I got an error.
1  
2  
3  
4  
5  
test.java:5: cannot find symbol
symbol  : class Controller
location: class test
        Controller[] ca = ControllerEnvironment.getDefaultEnvironment().getControllers();
// and some more...


I know I should place the jinput.jar in the classpath. Can anyone tell me: "How I can compile the class with the jar in the same directory?"

at the moment I compile and run the code with
1  
2  
# javac *.class
# java test
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.

radar3301 (12 views)
2014-09-21 23:33:17

BurntPizza (31 views)
2014-09-21 02:42:18

BurntPizza (22 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (29 views)
2014-09-20 20:14:06

BurntPizza (33 views)
2014-09-19 03:14:18

Dwinin (48 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (103 views)
2014-09-10 06:39:09

Tekkerue (51 views)
2014-09-09 02:24:56
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!