[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Some problem with WinXP Home and PyGame 1.7.1



I think it will be the best to write more about my problems during the 
development of my app. (Perhaps somebody will make some use of this 
story? ;-) )

Well, I got some problems with music. When the same app was playing music 
and doing the animation, FPS dropped from 150+ FPS to about 30+ FPS on my 
faster machine, under GNU/Linux. Since I find my machine quite fast 
(Celeron 2.4 GHz + 512 MB RAM), this was unacceptable for me, so I started 
looking for some workaround for this problem. Finally I decided to write an 
additional app - a music server. My main app was starting the server, that 
was loading the music and played it on demand. With such a trick I was able 
to get 150+ FPS and have some nice music in the background. That's the way 
it all worked under GNU/Linux. Well, it still works.

Under Windows I experienced more problems. The main problem was that I 
wasn't able to write the client program for my music server. The client's 
code was very simple:

   s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
   s.connect( ('', PORT_NUMBER) )  # PORT_NUMBER = 50000

After s.connect I always got the error message (nevertheless of the port 
number I tried):

  socket.error: (10049, "Can't assign requested address")

So I decided to throw the server away and to put the playing code directly 
in my app. And I ended up with the 15-25 FPS.

So far my workaround for this problem was switching to a lower screen 
resolution (640x480, to be exact). After this change I was able to get 30+ 
FPS. Not so bad, but - it was much better on my old Celeron 800 MHz 
machine, running GNU/Linux (with the music server mentioned before).

When I made a self-executable version of my app, I tried it on the same 
machine (Celeron 2.4 GHz), under W2K Prof. I got 25+ FPS. Somewhat worse 
result.


The following values were observed on the same machine, in the same screen 
resolution.

GNU/Linux: normal session, one terminal opened, FireFox + KMail, IceWM. 
Without sound I got 150-250 FPS.

Windows XP: normal session, I have no idea what ran in the background, since 
I don't know too much about Windows systems. I hadn't run any apps, though. 
Without sound I got 30-45 FPS.


Oh, BTW, after switching to 640x480, I got fullscreen in 85Hz. I don't know 
why, though.


And that's all about my experiences. Now about the general technique of 
animation. I haven't invented anything special. My (pseudo) code is as 
follows:

   loop:
     rects_to_update.extend( draw_all_objects )
     pygame.display.update( rects_to_update )
     remove_all_objects_from_the_screen
     update_all_objects

(Well, the code lacks removing all the old "dirty rects" from the list, but 
in my real code it was done.)

So, AFAIK, my technique was the fastest one known in the PyGame world. I 
haven't been updating whole screen (as it is done in most apps, that I have 
checked - e.g. the wonderful game "Trip on a Funny Boat", where the screen 
is updated with the pygame.display.flip() function). I have been updating 
only those rects, that were affected by some drawing/blitting operations.

And the fact is that after exchanging pygame.display.flip() with 
pygame.display.update( list_of_dirty_rects ) I got very significant 
increase of FPS. So I decided to stay with that faster code. Later I 
removed those HWSURFACE and DOUBLEBUF under Windows and my app finally ran. 
Well - it ran, but it was much, much slower than under my GNU/Linux.


This is my first app, that I have written with PyGame. I'd like to write 
some games for kids in the future. I think I'll use a lower resolution 
(320x240? 320x200?) in order to get better performance.

Eventually I might end up with making my own Linux Live-CD distro, that runs 
my PyGame apps directly after booting (for all those poor people, who use 
Windows systems ;-) ).


And one more thing. Now, when my app is ready to be deployed, I'd like to 
thank all the people, who tried to help me. I really appreciate your help. 
I wanted to make the final release of my app for Monday, and without your 
help it would be impossible to achieve.