Delayed key-event ?

M

marc

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 ?
 
S

S. Balk

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)
 
M

marc

However, I noticed that on slower machines (233 MHz),
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 ?
 
S

S. Balk

However, I noticed that on slower machines (233 MHz),
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top