Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Delayed key-event ?

Reply
Thread Tools

Delayed key-event ?

 
 
marc@zand.com
Guest
Posts: n/a
 
      08-15-2003
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 ?
 
Reply With Quote
 
 
 
 
S. Balk
Guest
Posts: n/a
 
      08-15-2003
> 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)


 
Reply With Quote
 
 
 
 
marc@zand.com
Guest
Posts: n/a
 
      08-15-2003
>> 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 ?
 
Reply With Quote
 
S. Balk
Guest
Posts: n/a
 
      08-15-2003
> >> 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 )

If the game-thread-priority is very low, other threads will take CPU-time
that would normally go to the game-thread.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ratio of Bytes Delayed to Bytes Sent netproj Cisco 0 12-21-2005 08:08 PM
Netscape 8 beta delayed Leonidas Jones Firefox 4 02-17-2005 08:17 PM
Calendar alarms delayed William W. Plummer Firefox 2 12-16-2004 01:49 PM
Delayed Instantiation - delayed.rb matt Ruby 8 06-19-2004 08:08 PM
Delayed Instantiation - delayed.rb matt Ruby 1 06-17-2004 01:43 AM



Advertisments
 



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