Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  JInput question  (Read 1792 times)
0 Members and 1 Guest are viewing this topic.
Offline kuldar

Senior Newbie





« Posted 2008-07-10 12:28:47 »

Hey! Im making a controller config option for my game and I came across a little bug. Program works like this:
If Button is pressed on config screen, it calls for input.update() which polls every device (limited it to keyboard and gamepads) and returns a vector of strings. Now config program reads firstElement of the vector and assigns it as label text.
Anyways, if you pressed lets say "any" key before actually pressing any button and then pressed the button to assign a value, it would assign it as "any" key. Is there a way to clear input buffer or smth? Smiley

Question 2: Is it good to save config as a file and in the main program if any key is pressed it checks if that key's value is assigned to any function? (eg. Player 1 assigned "X" key to attack on his gamepad and if "X" key is pressed in game, it would make him attack?)
Offline kuldar

Senior Newbie





« Reply #1 - Posted 2008-07-15 09:28:50 »

Nice to see that this forum is full of active members.  Undecided
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #2 - Posted 2008-07-16 08:31:28 »

No, there is no way to clear the buffer. If you know you are going to press a key to get past the menu, read the first value and ignore it.

Yes, saving the config is a good idea.

Sorry for going away for a week, I'll try not to take any holiday and inconvenience anyone again :p.

Endolf

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kuldar

Senior Newbie





« Reply #3 - Posted 2008-07-20 18:31:14 »

Ty! Since the subject is jinput question, I'm going to ask another question about it. Smiley
Is it normal if my comp can flip through empty program like this:

class Test
{
    public static void main(String args[])
    {
        int frames = 0;
        long timer = System.currentTimeMillis();
        while(true)
        {
            if(System.currentTimeMillis() >= timer + 1000)
            {
                System.out.println("fps: " + frames);
                frames = 0;
                timer = System.currentTimeMillis();
            }
            frames++;
        }
    }
}

-> about 17 million times per second and with input checking for Keyboard and 2x Joysticks(with exclusion of additional hardware like mouse, etc) about 45 000 times/s or does my jinput code blow? Smiley

E: Nevermind after I used randomly colored and positioned QL_QUADS those frames were 585 per update w/o jinput and 550 w/ it.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

Riven (5 views)
2014-07-23 21:16:32

Riven (6 views)
2014-07-23 21:07:15

Riven (6 views)
2014-07-23 20:56:16

ctomni231 (40 views)
2014-07-18 06:55:21

Zero Volt (36 views)
2014-07-17 23:47:54

danieldean (30 views)
2014-07-17 23:41:23

MustardPeter (32 views)
2014-07-16 23:30:00

Cero (47 views)
2014-07-16 00:42:17

Riven (48 views)
2014-07-14 18:02:53

OpenGLShaders (38 views)
2014-07-14 16:23:47
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!