Skip to main content
gamedev.net
🔒 Locked

[java] applet fps

Started by qx452 Apr 5, 2002 at 7:08 PM 14 replies 1k views
Original Post
qx452
qx452
The fastest i''m able to get an Applet''s paint(Graphics) method to be invoked (therefore the contents of the screen change, therefore the FPS) is 26 times a second. Is this slow for an applet? The paint method has nothing major in it to slow it down; it just increments the frame count and prints it. What is a reasonable FPS for an applet to try to achieve? Thank you.
Soulice
Soulice
Anything over 20fps is enough to fool the eyes. My online game applet averages between 26-29. My code is set to 30 fps. Dont need it faster so I havent tried to.



-Soulice
-Soulice
Chaoslab
Chaoslab
I find it is faster to not use the paint method, just overried paint(Graphics g) & update(Graphics g) with empty methods

and....

private Graphics gm;

public void init()
{
gm = this.getGraphics();
}

now you can draw from your main thread which is faster as paint will run concurrently to your main thread.

Hope that helps....

:-)
ujhkfkfk
Idej-Avaj
Idej-Avaj
quote:
Original post by Soulice
Anything over 20fps is enough to fool the eyes. My online game applet averages between 26-29. My code is set to 30 fps. Dont need it faster so I havent tried to.



-Soulice


how do you set your code to a specific FPS?
Jiim
Jiim
You can only do it roughly, hence the set to 30 but running at 26-29 bit.
I don''t think it''s a very good programming practise for games myself but you would do it by using the wait() method.

JJ.
www.javage.net
Chaoslab
Chaoslab
Roughly! You gotta be kidding!

You can set frame rates much more accurately than that.

When I finally got round to finishing Nebuloids I had problems with governing it. Ran a bit fast on some PC''s and System.getCurrentMillis() is only good for 50ms grained samples.

All you have to do is have a seperate time thread that sleeps to the ms you want and increments a counter and you''re sorted!
ujhkfkfk
Jiim
Jiim
Perhaps, but I still can''t see the purpose in doing it, what happens if it runs on a machine that can''t manage 30 fps??? Or, if it runs on a machine that can manage twice that much then you''re not making full use of that machine. Don''t think people would be too happy if id programmed their games like that!

JJ.
www.javage.net
Idej-Avaj
Idej-Avaj
What I guess needs to be answered then is: How to set the actual "velocity" of the object in motion... a velocity that will be the same no matter the framerate. That way, any computer can run the game and get the same gameplay... if the framerate is 60fps or as low as 15; because the images would be moving at the same speed (pixels per second).
Chaoslab
Chaoslab
Frame rate vs Velocity is a good way to look at it (though I can''t be bothered coding it yet).

When you code something you always have to keep your optimal target frame rate / platform in mind.

For example my next games target plat is a celeron 500 at least 50fps. The dev tools I am coding are targeted at more high end PC''s as decient dev machines have to be grunty!

:-)

ujhkfkfk
Jiim
Jiim
I''ve written an article for my (new) website at www.javage.net on how to achieve frame-rate independant movement, it''s got a simple example on how to get started.

Coincidentally I''ve also written an article covering 2D pixel-accurate collision detection, it''s not currently on my site as it''s waiting in the queue to feature here, should feature in 4/5 weeks from what I''ve been told.

JJ.
Idej-Avaj
Idej-Avaj
Thanks! I had tried to do something like that before, but your version of it seems much more sensible.
Soulice
Soulice
I am using a special class that takes an int for ist fps. The class does its own adjustments for framrate synching. It seems to work very well and from the 400+ users that have tested my game they all seem to get the same performance. Which is the goal.

Jim, I have made a number of enhancements since your last visit there and I think you see that its much smoother.






-Soulice
-Soulice
qx452
qx452
Thank you for your answers. I am sorry it took so long for me to reply. Chaoslab''s method of not using the paint method is interesting and I will try it. From the first reply, it sounds like 27ish is a reasonable framerate.

Topic Locked

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

Sign in to reply to this topic.