Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Increasing Animation performance

Started by prophecy Feb 12, 2001 at 8:34 PM 15 replies 900+ views
Original Post
prophecy
prophecy
What is the best ways to increase animation performance. I have been looking around, but I''m not finding much good info. I am pretty sure the best way to do it would be to only redraw the areas that have changed, but what is the best way to do this? prophecy
prophecy
prophecy
prophecy
I think i answered my own question.

If you set the clip on the Graphics2D object you can substantially increase performance.

g2.setClip()

Set this to only draw the background area that needs to be drawn, then draw your new changes with the clip set back to the full size.

prophecy
prophecy
prophecy
prophecy
I think the best bet for you here would be to have the entire (if it''s not too big of course) map in an BufferedImage object then when you are drawing to the screen, just clip the area of that image into the Graphics object.

BufferedImage map ...
mapg.setClip(x,y,w,h); // depending on what you want to show, width and height would be displayable area.

then draw that to the Graphics2D object.

Try that and let me know if it works for you.


prophecy
prophecy
prophecy
prophecy
Why do you use the System.currtimeMillis() function? Why not just sleep the thread for however many milliseconds you want?

prophecy
prophecy
Jerry Lynn
Jerry Lynn
We have a FAQ entry on the timing resolution issue...

http://games.cpbinc.com/faq/theory.asp#t2
Jiim
Jiim
Mmmm... I ain''t keen on any of the alternatives mentioned in the FAQ, I want to keep it pure Java, which rules out all the alternatives except for the JFM, and it is debatable if the JFM is more pure Java than any of the others.

I reckon that what I''ve got in mind should work fine, I tried it on my machine, hard-coding a value for the time increment for each frame and it worked very well, I just need to write a piece of code that is going to calculate and correct this value on the fly so that it is uniform across different machines, shouldn''t be too difficult.

Dewi.
c_wraith
c_wraith
quote:

We have a FAQ entry on the timing resolution issue...

http://games.cpbinc.com/faq/theory.asp#t2



Hey! That quote you start that section in the FAQ with is from me, not Jacob Marner.

http://www.gamedev.net/community/forums/topic.asp?topic_id=31877

You of course have my permission to use it... Could you just straighten out the crediting?
c_wraith
c_wraith
Thanks. =)
javanerd
javanerd
I''ve said this before and I think someone else has noticed this too: The JMF timers are no better than the System.currtimeMillis() function. The resolution is unfortunately the same.
-Pasi Keranen
Jiim
Jiim
I implemented the method I described in a previous post and it has worked very well as a work-around to the low resoulution of the timer. Although the complexity of each level varied, on any given level the frame rate was stable enough for me to be able to do what I described with quite astounding effect. I found that the best kind of time-frame to use was something in the region of 4-5 seconds with sampling the frame rate once a second, the game would run slightly faster than it should do sometimes due to a low frame-rate in the previous second but using a time-frame of 4-5 seconds would overcome this.

I don''t mind but I could write a short piece about this if there was an interest??

Dewi Williams.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.