Dmitry Borisov | 1 May 2004 02:01
Picon

[pygame] Can pygame have all compiled modules in one file ?

Pete et all,
I'm just curious, is there any posibility to have compiled pygame pyd/so files to be in 1 file ?
I understand that you want some flexibility by loading them online and having some vars from OS, but still want to decrease number of files I'm delivering to the users to minimum. Right now when I compile with py2exe it produces about 18 .pyd files for pygame.
 
Dmitry/
Bob Ippolito | 1 May 2004 07:08
Gravatar

Re: [pygame] Can pygame have all compiled modules in one file ?

On Apr 30, 2004, at 8:01 PM, Dmitry Borisov wrote:

> I'm just curious, is there any posibility to have compiled pygame 
> pyd/so files to be in 1 file ?
> I understand that you want some flexibility by loading them online and 
> having some vars from OS, but still want to decrease number of files 
> I'm delivering to the users to minimum. Right now when I compile with 
> py2exe it produces about 18 .pyd files for pygame.

It's probably possible to build a static python that includes all of 
these things, but it is FAR more trouble than it's worth.

-bob

Michael | 1 May 2004 07:54
Picon

Re: [pygame] Can pygame have all compiled modules in one file ?


>> I'm just curious, is there any posibility to have compiled pygame 
>> pyd/so files to be in 1 file ?
>> I understand that you want some flexibility by loading them online 
>> and having some vars from OS, but still want to decrease number of 
>> files I'm delivering to the users to minimum. Right now when I 
>> compile with py2exe it produces about 18 .pyd files for pygame.
>
>
> It's probably possible to build a static python that includes all of 
> these things, but it is FAR more trouble than it's worth.

Can't you include all that stuff in a zip file and load then include the 
zip file in your modules path?

Jan Ekholm | 1 May 2004 09:31
Picon

Re: [pygame] Jerky motion in window--not in fullscreen

On Fri, 30 Apr 2004, Eric Burgess wrote:

>I'm using pygame + pyopengl to create a scrolling game, and it's working
>great.  In fullscreen, everything is just as smooth as it could possibly
>be, but I get some stuttering when I run in a window.  My game isn't
>missing frames; I had it log elapsed times during frames and they were
>all 0 or 1 ms, with a few 2, 3, 4 thrown in, but nothing higher.

Maybe the stuttering somehow has to do with the redrawing not being
synchronized to the screen refresh? If you repaint in Pygame while the
screen is being repainted you could see tearing and maybe some stuttering.

--

-- 
  The trouble with being a god is that you've got no one to pray to.
                                        -- Terry Pratchett, Small Gods

Bob Ippolito | 1 May 2004 16:25
Gravatar

Re: [pygame] Can pygame have all compiled modules in one file ?


On May 1, 2004, at 1:54 AM, Michael wrote:

>
>>> I'm just curious, is there any posibility to have compiled pygame 
>>> pyd/so files to be in 1 file ?
>>> I understand that you want some flexibility by loading them online 
>>> and having some vars from OS, but still want to decrease number of 
>>> files I'm delivering to the users to minimum. Right now when I 
>>> compile with py2exe it produces about 18 .pyd files for pygame.
>>
>>
>> It's probably possible to build a static python that includes all of 
>> these things, but it is FAR more trouble than it's worth.
>
> Can't you include all that stuff in a zip file and load then include 
> the zip file in your modules path?

No, you can not load a dll directly from a zip file.  You could put 
them in there, uncompress them at start, load them, and then delete 
them.. which may or may not work.  But again, more trouble than it's 
worth.

-bob

Pete Shinners | 1 May 2004 20:45
Favicon
Gravatar

Re: [pygame] Can pygame have all compiled modules in one file ?

Dmitry Borisov wrote:
> I'm just curious, is there any posibility to have compiled pygame pyd/so 
> files to be in 1 file ?
> I understand that you want some flexibility by loading them online and 
> having some vars from OS, but still want to decrease number of files I'm 
> delivering to the users to minimum. Right now when I compile with py2exe 
> it produces about 18 .pyd files for pygame.

I don't think it could be done without rewriting how pygame modules work 
with each other. There are probably ways you could clean up a py2exe 
distribution. First you could just hardcode some subdirectories into the 
sys.path and after you build the executable, move the PYDs and DLLs into 
that directory. I'm pretty sure all the DLL's will be found as long as 
they are in the same directory as the PYD.

I've saw someone had a project where they hacked py2exe to put the PYD 
files into a subdirectory. Can't remember anything else about it, but it 
exists out there somewhere.

A messy install directory isn't the end of the world. For everything 
I've used PY2EXE on I wrap it up in a nice installer with Start Menu 
icons for the EXE, the README, and anything else of interest. I doubt 
any users have really ever looked inside the actual game directory.

Ludwig Auer | 1 May 2004 21:23
Picon
Favicon

[pygame] Paralax snow flaks: Some tipps for enhancing the performance?

Hello!

I just started Programming in Python & Pygame and my first Experiment  
was a simple Paralax Starfield. This worked very well, so i added some  
stuff to simulate  snow fall (with the sinus function). No Problem at  
all...

But when I tryed to extend the resolution of my programm (from 400x400  
to 1024x768) i noticed obvious performance problems. In measure of the  
fps I gained around 15 fps compared to 40-50 fps in 400x400

I don't really understand this ... There are no more flake-positions  
which have to be calculated!

Some guys in the #pygame irc channel told me to implement the profile  
module, to figure out, which part of my code thwarts my programm, but  
it didn't actually work...

So, here are my questions:

- How can i implement this profile module
- What does this loss of fps in higher res. rest upon? My first  
"Programming Tool" was this Game-Basic-Dialect BlitzBasic, there the  
fps-difference isn't so clearly.
- Do you have any tipps to enhance the performace of my pygames in  
general? How would you code things like my example?

So, here is the Code:

------------------------------------------------------------------------ 
---------------------------------------

#Schnefall 0.1

#Imports
import pygame, random, math
from pygame.locals import *

#Konstanten
MAX_FLOCKEN        = 100
MAX_FLOCKEN_SPEED  = 5
MAX_FLOCKEN_SIZE   = 3
SCREEN_HEIGHT      = 400
SCREEN_WIDTH       = 400
SIN_FREQUENZ       = 2

#Klassendefinitionen
class Flocke:
     #Initialisierung jeder neuen Flocke
     def __init__(self):
         self.speed = random.randint(1,MAX_FLOCKEN_SPEED)
         helligkeit = random.randint(20*self.speed,50*self.speed)
         self.color = (helligkeit, helligkeit, helligkeit)
         self.size  = random.randint(1, MAX_FLOCKEN_SIZE)
         self.ypos  = random.randint(1,SCREEN_HEIGHT)
         self.xpos  = random.randint(1,SCREEN_WIDTH)
         self.angle = random.randint(0,360)

     #Methode zum Darstellen der Flocken
     def draw(self):
         screen.fill(self.color, (self.xpos, self.ypos, self.size,  
self.size))

     #Eigenschaften einer Flocke updaten
     def update(self):
         self.ypos  = self.ypos  + self.speed
         self.xpos  = self.xpos  + (math.sin(self.angle)*5)
         self.angle = self.angle + 0.1

         if self.angle >= 360:
             self.angle=0

         if self.ypos > SCREEN_HEIGHT:
             self.ypos = 0

#Standardinitialisierungen
pygame.init()
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT),  
HWSURFACE|DOUBLEBUF)
pygame.display.set_caption('Paralaxer Schneefall')
pygame.mouse.set_visible(0)

#Hintergrund erschaffen
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((0,0,0))

#Erschaffen der Sterne
flockerl = []
for x in range(0,MAX_FLOCKEN):
     flockerl.append(Flocke())

#Main Loop
def main():
     frames=0
     ticks = pygame.time.get_ticks()

     while 1:
         screen.blit(background, (0,0))

         for jede_flocke in flockerl:
             jede_flocke.update()
             jede_flocke.draw()

         pygame.display.flip()

         frames=frames+1
         keyinput = pygame.key.get_pressed ()
         if keyinput [ K_ESCAPE] or pygame.event.peek(QUIT):
             break
     print "fps:  %d" % ((frames*1000)/(pygame.time.get_ticks()-ticks))

if __name__=='__main__':
     main()

Eric Burgess | 1 May 2004 21:38

Re: [pygame] Paralax snow flaks: Some tipps for enhancing the performance?

Ludwig Auer wrote:

> Some guys in the #pygame irc channel told me to implement the profile  
> module, to figure out, which part of my code thwarts my programm, but  
> it didn't actually work...

It should be very easy to profile your code.  Just fire up the 
interactive prompt, and do this:

 >>> import snowflakes   # or whatever you named it
 >>> import profile
 >>> profile.run('snowflakes.main()')

After you exit from your snowflake program, you should see a lot of 
numbers along with function names.  For each function, you'll see:

'ncalls' - the number of times a given function was called. 
'tottime' - the total time spent within the function
'cumtime' - the "cumulative time", which is the time spent in that 
function, plus any functions that were called from within it

Profile it at low resolution, then at high resolution, and see which 
functions have the greatest increase in time.  That should show you 
where the problem is.

I hope this helps,
Eric Burgess "mojo-"

Michael | 1 May 2004 21:55
Picon

Re: [pygame] Paralax snow flaks: Some tipps for enhancing the performance?


> But when I tryed to extend the resolution of my programm (from 
> 400x400  to 1024x768) i noticed obvious performance problems. In 
> measure of the  fps I gained around 15 fps compared to 40-50 fps in 
> 400x400

Just to take a random guess.. does the program not slow down near as 
much if you remove the step of blitting a background each pass through 
the loop?

Eric Burgess | 1 May 2004 23:02

[pygame] [announcement] SFont 0.1 for pygame

Download it from here: http://big-brain.org/files/python/pygame/

I've created a small module that allows the use of SFont bitmapped fonts 
with pygame.  The SFont format makes it simple to use proportional-width 
bitmapped fonts.  More information on SFont can be found at 
http://www.linux-games.com/sfont/

The SFont format is cool because:

    * It supports multi-colored fonts
    * It is easy to use
    * It's easy to create your own fonts!
    * You can choose between a large number of fonts
    * Handle as many fonts as you like at the same time
    * Simple font format - all data is stored in one png!
    * It's well tested and used in many projects
    * You don't have to deal with strange file formats: all font info is
      stored in one image file
    * The fonts are not dependant on the used image file format

My implementation has the following features:

    * Easy to load from an SFont file: font = sfont.Font('file.png')
    * Automatic word-wrapping at a specified pixel width
    * Ability to blit directly to an existing surface, or return a new
      surface with the text rendered onto it (this is useful when the
      same text needs to be shown many times)
    * Unicode support (untested, and requires an SFont file with the
      desired characters--a few are available on the net)

If anyone finds this useful, I'd appreciate any feedback or bug reports.

Thanks!
Eric Burgess "mojo-"


Gmane