# java capping fps [duplicate]

hello again I have a basic platformer game and I want to make an fps counter and cap the fps to 30 but I don't know how. I want this because when I start up the game sometimes the character moves realy fast and other times very slow.

What you are probably doing right now is in every frame you say position += velocity;, where position is in units of distance (whatever they may be--pixels, meters, etc.), and velocity is in units of distance per frame.
However, what you should probably do is have velocity instead be in units of distance per time instead of distance per time. Then what you would do is position += velocity * frameTime;, where frameTime is 1/FPS, and is in units of time (seconds, to be specific).