Question

Right now I'm using Java Swing timers to repaint my game etc. On my gaming computer it runs at the speed I desire, but on the school computer is runs very slowly. Sometimes it runs very slowly on my computer as well.

So would using threads make it consistent? Could I keep the swing and do longs with current and past event times? I tried that, but I was having a lot of trouble with it. I've already done timertasks with the weapon delay, would that be consistent?

My swing stuff is very similiar to this: http://zetcode.com/tutorials/javagamestutorial/animation/

If you scroll down there is the threads part.

Thanks.

Was it helpful?

Solution

Short answer: not necessarily. Threads likely have nothing to do with it. In fact, depending on the number of threads the machines can run, the overhead to spin one up, and the actual parallel work you do, you may wind up performing worse.

Performance is subject not just to the quality of code, but to the quality of the machine running it. So, it stands to reason that I'd expect a faster machine geared to gaming to perform better with a game than a school computer using lesser hardware.

That's not to say that your code couldn't use a refactoring, but in general, a machine that is better performing will be able to handle things better than one that...isn't.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top