You are not logged in.
Hi,
When Open Sonic is running, Windows Task Manager shows that my CPU is always at 100% usage, even when the game is paused and minimized. This makes my CPU fan run more noisily, makes my laptop use up its battery faster, and is not so good for the environment. Also, when I'm not playing, I sometimes leave the game paused and minimized for days on end so that I won't lose my progress, so this affects me for days.
Please make Open Sonic use less CPU when possible, especially when paused.
I'm using version 0.1.2.
Offline
ok. We'll take a look into it.
Offline
Hi. First of all congratulations for this project. It's a great and game.
Secondly, I think this problem would be solved easily by modifying the main.c file and adding a rest (...); instruction after the rendering. So we will free the CPU the rest of the frame cicle rest (FRAME_INTERVAL - t; where t = game_timer () - last_time;). Also I have deleted the for (;;) in time control section.
This solution doesn't run exactly at 100 fps but (in my computer) reduces the CPU occupation arround the 10%. Of course, no else knows your code better than you, so my solution maybe is a bit ugly and you could do so much better. I only wanted to share an idea.
Best wishes to you and to this great project.
Offline
In my ubuntu 9.04 it loads CPU at 100% too, just for info. Before post #1 I was thiking that it`s linux platform problem. That problem has high priority.
Offline
I would really like open sonic to not consume 100% CPU, it seems the problem lies in the choice of timer for the game. I wouldn't have gotten very far without what joserc87 posted, but I know a bit of programming and I took a look.
To improve joserc87 solution, the following lines should replace the for loop:
current_time = game_timer();
delta_time = current_time - last_time;
rest(MIN_FRAME_INTERVAL - delta_time);
it seems delta_time is needed to properly show the current fps. The game seems to handle going into lower fps when the cpu is not powerful enough though. The only trouble is that when using small screen mode, the fps is doubled and the speed of the game is halved.
Could one of the programers also explain more about that for loop, I can't seems to understand what it all does. It almost seems that the game_timer() goes back to zero, otherwise current_time would never be less than last_time.
This is a great game and I would like to help as much as I can to improve this portion of the game.
Offline
Using rest() in the main loop is usually a bad idea, as you never know when the operating system is going to take the control back to the game. Hence, it may cause an unnecessary drop of the frame rate.
That for loop is a busy waiting technique. I think a better approach would consist of using semaphores (which would require pthreads), but I'll postpone this issue to some other version, as we need to release 0.1.3 really soon.
Offline