It looks like you're new here. If you want to get involved, click one of these buttons!
My game runs approximately between 40 and 220 FPS.
How I can do to make this run a maximum of 30 FPS?
And how do I get to run at 60 FPS?
mi juego corre aproximadamente a entre 40 y 220 FPS.
¿Cómo puedo hacer para que este corra como máximo a 30 FPS?
¿Y cómo hago para que corra a 60 FPS?
Comments
My advise is to always use VSync, this way you won't get tearing.
If it doesn't work, it might be your graphics driver that are overriding your application decision.
As for your logic code, you can cap the main clock at 60FPS via config, or better, create your own clock at 30FPS and register your update function to it. However I wouldn't really worry about that unless you're doing a lot of expensive stuff and can't reach 60 FPS when letting things run on the core clock with VSync on.
Pseudo-code solution 1 (simple, but not very effective)
I thinking also in a complex second solution, but for now, i want to make solution 1... how can i do this using orx functions?
Edit: i'm created a complex solution, but i also need the functions:
getTime and Delay with hight presition, from orx
EDIT: "control + z" to my comment. orx does have precision!
It works! but at 10 fps less than expected. https://forum.orx-project.org/uploads/legacy/fbfiles/files/FPS.zip
Use:
Creating fps controller in a class
Using fps controller
The structure orxCLOCK_INFO contains, among other info, both the time elapsed since the initialization of the clock and the current delta time (ie. your current frame duration).
You can even apply modifiers to a clock to either consolidate the DT (ie. slowing down time instead of stuttering), fix the DT (for a lockstep scheme, for example) or do time stretching.
You should *always* use the info given by the clock calling you if you want time coherency.
Any time spent in your update function is taken into account in the whole frame DT.
If you want no tearing and work in VSync mode at 60FPS, the whole frame should take a maximum of 16.6ms. You can see very precisely where time is spent in both orx and your code by using the profiler version of orx and enabling the profiler's display:
If you want to profile your own section of code, you have to use the orxPROFILER_PUSH_MARKER()/orxPROFILER_POP_MARKER() macros and define __orxPROFILER__.
could you give me examples?
I'm using vsync... mmm what if i want a variable frame rate?
I'll read about it, to use it
PD: Excuse the question, but do you know a community of "orx" in spanish? because I have difficulties to express what I think, because I don't speak english.
New question added
Can you adapt my FpsAbstract/FpsSimple classes to work with orxCLOCK_INFO ?
Simple solution correction (only tested on Windows)
FpsSimple.cpp
Well the first example would be to look at the tutorial #2 named Clock. It shows how to do time stretching. As for fixed/consolidated DT I could write a simple example later, sure.
With default setting, orx is using a consolidated core clock with a lower limit of 10 Hz. That means that the clock will always use the real time and update as fast as possible most of the time, except when too much work is done and the actual framerate drops under 10 FPS. In that case, it'll always send a DT of 0.1s which will result in actual slowdown of the game.
Note also that the physics simulation is using an accumulated DT to prevent as much as possible divergences in the simulation.
Well, in that case I need to ask you why?
For most games (with the exception of lockstepped network games) you shouldn't pay attention to the framerate in the first place.
When your game is done, or close to be done, if you really can't make it at the native 60FPS (in most cases), you should consider capping it at 30FPS.
Beside this, I'm not sure why you should care about the game's framerate.
I understand your pain and that's a good question. I'm sure there are some other native Spanish speakers that came over the time, not sure if there are any around still. You can start a thread on the general forum looking for some.
If you're enough people, I could even open a new Spanish section as I did for Chinese.
Well, that's the thing, you don't need your class at all. If you're only goal is to limit at 60FPS and VSync doesn't do anything, it means that your graphics driver is preventing you from doing it. In which case you need to either update your graphics driver and/or go into its setup application and make sure that VSync can be toggled by programs.
then what do I do?
1) I have to make a new clock to 60hz / 30 hz
or
2) modify the core clock frequency? <- I need examples
what is the core clock default frequency?
But I'm asking again, for what reason do you want to fix your framerate at 60 Hz?
I told you "60" because that's what I'm used to. And 60 is much nicer than 30:) and do not see much difference with higher fps.
60 hz??? jaja.... misstake! 60hz/1000
i understand this, but, i don't know how change orx core clock frecuency :P and, what is the core clock default frequency?
But again, having a fixed of varying framerate shouldn't matter at all as long as you're using the DT stored in the orxCLOCK_INFO structure.
This defines a clock named Clock1 with an actual update frequency of 50Hz.
As seen in SettingTemplate.ini:
This limits your core clock at 60 Hz.
i will cry! jaja i don't understand :S I think I need a break..
I leave you with one last question: Do you have a game made with orx? so that I can use as reference and fully understand the use of orx... :side:
(In addition to the tutorials.)
This is cool! but, when you are on the move an object, it accelerates uncontrollably? because it happens to me
so, does this happens to ?
if this happens because of my video card, in another PC, will run correctly?
It's explained in the clock tutorial.
For example let's say you want to fill a gauge at the rate of X percent per second.
In your code you'll write:
No matter what your framerate is, your gauge will still fill at X percent per second.
And for games, there are a few out there, but only one with open source code I think. You want to check Mushroom Stew in this thread: https://forum.orx-project.org/discussion/2514#Comment_2832
If you don't care about lasting collisions, then you'd do something like:
This will give it a constant speed of value 'MySpeed' on the X axis.
Tomorrow I will read it in detail, thanks
Man! It's just what I need!
Jeje i don't understand English well, but I understand c++ code... Why not talk to me in c + +?
Tomorrow will prove these things, and tomorrow is the big day of trying to compile orx, we'll see what happens.
Thank you very much for the answers!
I'm glad the explanation went through in the end. I'll try code sooner next time!
{
orxVECTOR vPos;
orxObject_GetPosition(MyObject, &vPos);
vPos.fX += MySpeed * _pstClockInfo->fDT;
orxObject_SetPos(MyObject, &vPos);
}
I'm used this, and i don't like how it works
That was an exemple to show how to use a DT, for object's speed you should just really call orxObject_SetSpeed(), not orxObject_SetPos().
paused = not constant
All the distances are expressed in "world units" which turns out to be identical to pixels provided that your viewport covers your full display area and you don't have a zoom on your camera.
I think the best way is to experience it and see if your battery really goes down too fast when running your game and using another game as reference.