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

Re: [pygame] Weird lag



How is collision testing done? 200 sprites tested against 200 sprites
is a big difference from just testing 2-3 sprites against 200, in particular
if you do the iteration in Python.

/P

On 2009-03-01 (Sun) 08:51, Daniel Mateos wrote:
> Hey again,
> 
> In a 2d scroller game im making i seem to get FPS drops at random
> points, i am using the Clock class to keep it at a constant 60 fps and
> it never seems to go above 9%-15% cpu usage so im not sure what could be
> causing it.
> 
> Seems to run well for 90% of the time with spikes that drop the fps to
> 10-40 at some points in the level, other times it runs fine at exactly
> the same points and its not doing anything extra doing these spikes, im
> bliting about 100-200 sprites per frame.
> 
> Some quick profiler output, doesnt really tell me much tho:
> 
>  ncalls  tottime  percall  cumtime  percall filename:lineno(function)
>      1233   10.177    0.008   10.177    0.008 {built-in method tick}
>      1233    4.982    0.004    4.982    0.004 {pygame.display.flip}
>    153699    3.211    0.000    3.211    0.000 {method 'blit' of
> 'pygame.Surface' objects}
>    542520    0.424    0.000    0.424    0.000
> game_level.py:129(CheckOnScreen)
>      1233    0.419    0.000    3.889    0.003 game_level.py:56(RenderLevel)
>    487287    0.312    0.000    0.419    0.000
> game_level.py:105(CheckCollide)
>      1233    0.291    0.000    0.757    0.001
> game_level.py:122(CheckCollides)
>      3615    0.160    0.000    0.160    0.000 {method 'render' of
> 'pygame.font.Font' objects}
>         1    0.150    0.150    0.150    0.150 {pygame.base.init}
>         1    0.126    0.126   20.979   20.979 main.py:18(<module>)
>    487287    0.107    0.000    0.107    0.000 {method 'colliderect' of
> 'pygame.Rect' objects}
>         1    0.093    0.093    0.121    0.121 {pygame.display.set_mode}
> 493258/493031    0.048    0.000    0.048    0.000 {len}
>         4    0.048    0.012    0.048    0.012
> {pygame.imageext.load_extended}
>      1233    0.042    0.000    0.042    0.000 {pygame.event.poll}
>      1233    0.040    0.000    0.096    0.000 game_osd.py:79(DrawBar)
>         4    0.034    0.008    0.034    0.008 {method 'convert' of
> 'pygame.Surface' objects}
>      1233    0.033    0.000    0.805    0.001 game_level.py:44(update)
>         1    0.017    0.017    0.125    0.125 __init__.py:25(<module>)
>      1233    0.016    0.000    0.041    0.000 game_osd.py:106(WriteText)
> 
> Any help or suggestions for better profileing/tracking down the lag
> would be good :)
> 
> -- 
> Daniel Mateos
> http://daniel.mateos.cc