Currently, for my 2D game engine I use Thread.sleep() for my delay, however I've gotten feed back that my delay might drift a bit, so should I try and switch to swing.Timer?
Using Thread but should I use swing.Timer?
Page 1 of 16 Replies - 300 Views - Last Post: 08 October 2012 - 08:23 PM
Replies To: Using Thread but should I use swing.Timer?
#2
Re: Using Thread but should I use swing.Timer?
Posted 08 October 2012 - 09:52 AM
swing timer is even worse. The util timer tries to even itself out over time, and will work much better 
You could use Thread.sleep, so do I in my own game engine, but you just have to find a solution to the problems I wrote to you in the other topic. System.nanoTime() may be useful when adjusting the sleeping time.
You don't have to do any adjustments if you simply dont care, your game will still work.
You could use Thread.sleep, so do I in my own game engine, but you just have to find a solution to the problems I wrote to you in the other topic. System.nanoTime() may be useful when adjusting the sleeping time.
You don't have to do any adjustments if you simply dont care, your game will still work.
#3
Re: Using Thread but should I use swing.Timer?
Posted 08 October 2012 - 10:24 AM
Is your game really that fast paced that you need to worry about it? Would you even notice, or would it even affect game play? I doubt it. For most 2D games that aren't really that fast paced, and don't require big amounts of processing, I'd use a swing timer, as it is nice and simple. Your timer will call actionPerformed() roughly x after the end of the previous.
If I were using a thread, I would use a thread with a small, fixed sleep time of 2 or 3ms, then update your game logic and objects based on how much time has passed.
If I were using a thread, I would use a thread with a small, fixed sleep time of 2 or 3ms, then update your game logic and objects based on how much time has passed.
#4
Re: Using Thread but should I use swing.Timer?
Posted 08 October 2012 - 12:04 PM
Just keep in mind that is useless to repaint the sceen faster than every 16.666 millisecond as this is the frequency at which the screen hardware is refreshed
#5
Re: Using Thread but should I use swing.Timer?
Posted 08 October 2012 - 03:23 PM
That's only if you have a 60 Hz screen no pbl? Some screens support refresh rates of 75 and 80 Hz I believe.
#6
Re: Using Thread but should I use swing.Timer?
Posted 08 October 2012 - 03:38 PM
CPU speed has increased by a few hundred thousand in the last 30 years
MEMORY speed has increased by thousand in the last 30 years
DISK access speed has increased by a few hundred in the last 30 years
nobody bother increasing video refresh rate because the human eyes won't perceive the difference anyhow so why investing in increasing that speed
From an hardware point of view it is so simple to synchronize the refresh rate with the alternative current cycle that nobody ever looked for another solution
so 60/sec in North America 55/sec in Europe
MEMORY speed has increased by thousand in the last 30 years
DISK access speed has increased by a few hundred in the last 30 years
nobody bother increasing video refresh rate because the human eyes won't perceive the difference anyhow so why investing in increasing that speed
From an hardware point of view it is so simple to synchronize the refresh rate with the alternative current cycle that nobody ever looked for another solution
so 60/sec in North America 55/sec in Europe
#7
Re: Using Thread but should I use swing.Timer?
Posted 08 October 2012 - 08:23 PM
I can totally tell the difference on the 60 Hz and 120 Hz TVs when watching a Blu-Ray, but I concur with your point pbl as it makes a lot of sense in that regard.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|