Delayed key-event ?

Discussion in 'Java' started by marc@zand.com, Aug 15, 2003.

  1. Guest

    The game I'm working on has one, separate game-thread.
    When the player presses an 'arrow'-key, I just set a
    variable, which is read by this game-thread.
    When the player releases the key, I reset the variable.

    So far so good.

    However, I noticed that on slower machines (233 MHz),
    the key-released-event is somewhat delayed (only when
    the game-thread is running at the same time).

    In other words, when a key gets released, it takes a
    noticable amount of time before the key-released-event
    occurs (I can tell because I've put 'label.setText()'
    statements in the event-handlers).

    This really messes up the game-play ! :-(

    Has someone else ever experienced this ?
     
    , Aug 15, 2003
    #1
    1. Advertising

  2. S. Balk Guest

    > The game I'm working on has one, separate game-thread.
    > When the player presses an 'arrow'-key, I just set a
    > variable, which is read by this game-thread.
    > When the player releases the key, I reset the variable.
    >
    > So far so good.
    >
    > However, I noticed that on slower machines (233 MHz),
    > the key-released-event is somewhat delayed (only when
    > the game-thread is running at the same time).


    Your game-thread is taking to much CPU-time.
    1. pause the thread often for a few milliseconds (I don't like forced
    sleeps)
    2. lower priority of the game-thread (that's the way I do it)
     
    S. Balk, Aug 15, 2003
    #2
    1. Advertising

  3. Guest

    >> However, I noticed that on slower machines (233 MHz),
    >> the key-released-event is somewhat delayed (only when
    >> the game-thread is running at the same time).

    >
    > Your game-thread is taking to much CPU-time.
    > 1. pause the thread often for a few milliseconds
    > (I don't like forced sleeps)


    I'm curious, if you don't like 'forced sleeps', how do
    you pause your thread/game then ?
     
    , Aug 15, 2003
    #3
  4. S. Balk Guest

    > >> However, I noticed that on slower machines (233 MHz),
    > >> the key-released-event is somewhat delayed (only when
    > >> the game-thread is running at the same time).

    > >
    > > Your game-thread is taking to much CPU-time.
    > > 1. pause the thread often for a few milliseconds
    > > (I don't like forced sleeps)

    >
    > I'm curious, if you don't like 'forced sleeps', how do
    > you pause your thread/game then ?


    I use option 2. that you cut from your reply :eek:)

    If the game-thread-priority is very low, other threads will take CPU-time
    that would normally go to the game-thread.
     
    S. Balk, Aug 15, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. M P
    Replies:
    1
    Views:
    480
  2. matt
    Replies:
    1
    Views:
    401
  3. matt
    Replies:
    8
    Views:
    225
    Mauricio Fernández
    Jun 19, 2004
  4. HopfZ
    Replies:
    0
    Views:
    294
    HopfZ
    Jan 8, 2007
  5. Jeff
    Replies:
    4
    Views:
    136
Loading...

Share This Page