<div dir="ltr">Thanks,<div><br></div><div>the patch extension file must be .patch ? (I've no example on my disk and I forgot the git patch extension : so that I can paste your suggestion into gedit, and save it as a patch).</div>
<div><br></div><div>Regards</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/1 James Cameron <span dir="ltr"><<a href="mailto:quozl@laptop.org" target="_blank">quozl@laptop.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sat, Sep 28, 2013 at 01:42:50PM +0200, laurent bernabe wrote:<br>
> But as the computer where I inserted the key was a very old one (it<br>
> has an old AMD processor and it seems to me it has just 1GB of RAM),<br>
> the animation where too slow : very slower than the result I got on<br>
> my laptop (which has two processor at 2.19 Ghz).<br>
><br>
> Apart this, it works, and I should submit the bundle to ASLO soon.<br>
<br>
I suggest fixing performance soon.<br>
<br>
On Sat, Sep 28, 2013 at 05:54:30PM +0200, laurent bernabe wrote:<br>
> As my computer has 2*2.16Ghz processor, is it possible to configure<br>
> sugar-build so that the speed is "locked" under 433 Mhz ?<br>
<br>
No.<br>
<br>
You raise an important issue though. You must tune your activity so<br>
that it works on the slowest hardware you support. The CPU clock<br>
isn't the only cause of slowness.<br>
<br>
Looking at your:<br>
git://<a href="http://git.sugarlabs.org/hittheballs/hittheballs" target="_blank">git.sugarlabs.org/hittheballs/hittheballs</a><br>
in particular at hash 4533d1f2be64ef74d34129cf388919cfa36c8e91<br>
<br>
In main_game.py you have chosen 40 frames per second for self._FPS.<br>
<br>
This is a very high rate for an OLPC XO-1. You should lower this<br>
number as much as possible until just before the game is unpleasant<br>
for a new user.<br>
<br>
The reason this number is important is that it determines the CPU<br>
processing required for display update between each opportunity to<br>
respond to input.<br>
<br>
The display update pipe is a work queue. If the update rate is too<br>
high, then the main_game.py will _pause_ briefly on line 223, and this<br>
pause will prevent main_game.py from responding quickly to keyboard or<br>
mouse events.<br>
<br>
Also, you must add a call to self._clock.tick(self._FPS) when<br>
game_state is not NORMAL, and while in show_menu, otherwise the<br>
display update pipe will be flooded, and you _will_ have delays and<br>
massive power use, shorter battery time.<br>
<br>
If after doing the above the performance is still too slow, then a<br>
more advanced display update method is required. I use this method in<br>
the Netrek game client Gytha. The method is to maintain a list of<br>
rectangles that have been dirtied, and only update those rectangles<br>
instead of the whole canvas.<br>
<br>
(by the way, you should rename gpl-3.0.txt to COPYING, because that is<br>
the conventional name)<br>
<br>
Below is a patch showing some of the performance changes mentioned<br>
above:<br>
<br>
diff --git a/main_game.py b/main_game.py<br>
index 110ebf3..0e23fd9 100644<br>
--- a/main_game.py<br>
+++ b/main_game.py<br>
@@ -60,7 +60,7 @@ class Game:<br>
return<br>
pygame.init()<br>
self._LEFT_BUTTON = 1<br>
- self._FPS = 40<br>
+ self._FPS = 10<br>
self._MENU_LEVELS_RECTS_Y_GAP = 30<br>
self._MENU_LEVELS_RECTS_WIDTH = 345<br>
self._MENU_LEVELS_RECTS_HEIGHT = 60<br>
@@ -220,6 +220,8 @@ class Game:<br>
pygame.time.set_timer(USEREVENT + 2, 1000)<br>
<br>
while True:<br>
+ while Gtk.events_pending():<br>
+ Gtk.main_iteration()<br>
pygame.display.update()<br>
self._screen.fill(self._GAME_BACKGROUND)<br>
paint_result_bar(result_bar, self._screen)<br>
@@ -228,9 +230,6 @@ class Game:<br>
for ball in the_balls:<br>
paint_ball(ball, self._screen)<br>
<br>
- while Gtk.events_pending():<br>
- Gtk.main_iteration()<br>
-<br>
for event in pygame.event.get():<br>
if event.type == QUIT:<br>
pygame.quit()<br>
@@ -253,7 +252,6 @@ class Game:<br>
game_state = GameState.WON<br>
else:<br>
game_state = GameState.LOST<br>
- self._clock.tick(self._FPS)<br>
for ball in the_balls:<br>
ball.move()<br>
balls_collision.manage_colliding_balls(the_balls)<br>
@@ -270,9 +268,6 @@ class Game:<br>
self._RED)<br>
self._screen.blit(end_txt_surface, self._END_TXT_POS)<br>
<br>
- while Gtk.events_pending():<br>
- Gtk.main_iteration()<br>
-<br>
for event in pygame.event.get():<br>
if event.type == QUIT:<br>
pygame.quit()<br>
@@ -282,6 +277,7 @@ class Game:<br>
elif event.type == MOUSEBUTTONUP:<br>
if event.button == self._LEFT_BUTTON:<br>
return<br>
+ self._clock.tick(self._FPS)<br>
<br>
def show_menu(self):<br>
"""<br>
@@ -324,3 +320,4 @@ class Game:<br>
self._play_game(<br>
30,<br>
self._levels[selected_level_index])<br>
+ self._clock.tick(self._FPS)<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
James Cameron<br>
<a href="http://quozl.linux.org.au/" target="_blank">http://quozl.linux.org.au/</a><br>
</font></span></blockquote></div><br></div>