Hi everyone!
I’m new here and finally I’ve decided to sign in because I found this is the best place to learn java gaming techniques!! I hope I can help others too…
Well, here’s my question:
I’m building a “mini-engine” for a tribute game to “Monty” (from the C64 versions of “Monty on the run” and “Auf wiedersehen Monty”), and recently I solved a problem I had with some tear effects or glitches (I don’t know how to call it…) in my animation code. Basically what happened was that in my computer everything went smooth but when I ran the tests on my laptop I noticed this issues. I’m using page flipping and in my “flip” method I had this:
public class MyGraphicsClass implements MyGraphicsInterface() {
… some methods here
public void flip() {
//screen.dispose(); <-- doesn't work. once disposed it has to be retrieved again?
strategy.getDrawGraphics().dispose();
strategy.show();
try {
[b]Thread.sleep(10);[/b]
} catch (Exception e) {}
}
}
Now, instead of sleeping for 10 ms I try to make the loop take exactly 10ms so I changed it to this:
try {
[b]Thread.sleep( game.getLastLoopMsecs() + 10 - HiresTimer.getTime() );[/b]
} catch (Exception e) {}
Is this a good solution? Or is it better to keep a constant sleep time to let the OS “breathe” for a while? As I said, with a fix value is not so smooth in my laptop (Dell XPS)
Besides, I thought that as the game grows, every loop will take more time and the sleep time will be less and I don’t know if that’s ok or bad
Btw, for now I’m using Sun’s Perf class in my HiresTimer (Eventually I’ll have to use another system I guess… but atm I’m interested in getting the basics done)
Oh, and another thing: I’m using UPS instead of FPS, should I change to FPS for better performance or is UPS ok?