PDA

View Full Version : Some stuff I want to ask



Zaxuhe
06-11-2012, 03:35 AM
Well I have 3 questions... I'm going to start :)

the first one, a friend of mine have an android 2.1 device, I have send an apk to him and when he touched the screen at any time on any place (even on bare bones) it will crash, the device he is using was not designed for android 2.1 (its 1.5 but rooted), but most opengl games work even with touch, since I know its not my code, maybe you could test it? I'm also trying to fix it, but I haven't been able... or maybe I need to change something on the build target or parameters? the keyboard keys are being detected and working ok, just the touch kills the app

second one, is there a way to get time? like SDL_getticks or something like that? I want to shoot every 100 ms or so, and well I want to know if there is already a general way to get the time, or we will have to implement it?

if I set my game to run at 30 or 60 fps and the game runs at 15 fps, the update function will still be called 30 times? to keep the game physics and render speed fast and stable? (if the game runs at 8 fps and the update also gets down to 8 it will super slow,if the game runs at 1230812038120 fps and the update aswell it will run too fast :S) also at main.cpp I see int g_fpsLimit = 0; //0 for no fps limit (default) Use MESSAGE_SET_FPS_LIMIT to set can you give an example of how to send the message?

Thank you very much!

Seth
06-11-2012, 05:01 AM
Well I have 3 questions... I'm going to start :)

the first one, a friend of mine have an android 2.1 device, I have send an apk to him and when he touched the screen at any time on any place (even on bare bones) it will crash, the device he is using was not designed for android 2.1 (its 1.5 but rooted), but most opengl games work even with touch, since I know its not my code, maybe you could test it? I'm also trying to fix it, but I haven't been able... or maybe I need to change something on the build target or parameters? the keyboard keys are being detected and working ok, just the touch kills the app

second one, is there a way to get time? like SDL_getticks or something like that? I want to shoot every 100 ms or so, and well I want to know if there is already a general way to get the time, or we will have to implement it?

if I set my game to run at 30 or 60 fps and the game runs at 15 fps, the update function will still be called 30 times? to keep the game physics and render speed fast and stable? (if the game runs at 8 fps and the update also gets down to 8 it will super slow,if the game runs at 1230812038120 fps and the update aswell it will run too fast :S) also at main.cpp I see int g_fpsLimit = 0; //0 for no fps limit (default) Use MESSAGE_SET_FPS_LIMIT to set can you give an example of how to send the message?

Thank you very much!


Hmm, I suspect it has something to do with the touch input code, it actually has two methods and it switches to the "advanced" method if OS 2.1 is detected. Because this is a rooted hack of an old phone I don't think it's going to be something that will affect many people... step one would be to look at the debug log while it's running though.

Yes, use GetSystemTimeTick() to get the system timer in milliseconds. (every 1000, a second has passed)

The FPS limiter limits both update and render to the desired fps. If you want anything fancy (like locked step updates) you have to implement it in the app yourself. For less fancy but framerate independent speed, you can use speed*GetApp()->GetDelta() where you would normally use just speed.




To lock the FPS at a lower speed, you do it like this:

GetBaseApp()->SetFPSLimit(15);

(If you look in BaseApp.cpp, you'll see it's using MESSAGE_SET_FPS_LIMIT internally)

Zaxuhe
06-11-2012, 07:15 PM
Thank you very much! will try to fix on the android and if I can solve it, I will post a patch