This content has been marked as final. Show 2 replies
You're creating a busy loop, that will make your CPU (or one of the cores) go to 100% usage which is a killer to power consumption and noise and heat production. I advise you to visit java-gaming.org and go through he different articles you can find there to learn all about how to do game loops with a steady tick rate (the commonly used term "FPS").
The trouble with this is that most of the above commands will require several hundred milliseconds to complete (and animate).Well you'll have to fix that problem. A single frame of your game should be able to complete in around 20-25 milliseconds to get a smooth and steady update of 50-60 frames per second, if it takes so long to do stuff you have a serious performance issue that will kill any chance of you creating a game that moves fluently and has a decent response time to input actions. So you'll have to dig deep: WHY is it taking so long to do basic drawing stuff? I'm guessing it has something to do with improper use of transparency, but I can only guess when you don't share what technology you're using to do the actual drawing of graphics.
The problem isn't that the drawing code is too slow (I'm actually drawing about 1000 FPS and using mostly Graphics.drawImage()). The problem is that animations are time restricted. It is going to take several hundred milliseconds for my monster character to take a step because otherwise the player would not see it. So the game thread can at most update the monster to it's next frame, then exit and wait until the next call before continuing. I'm trying to think of an easy way to script a complex chain of these events.