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

Re: [pygame] Weird lag



hi,

try timing some parts...  Then you might be able to see where the lag
is happening.

Each frame you should be able to see that they are similar values.  If
they are not, you should be able to debug where your delay is.

Here's your mainloop end part modified to add a couple of timers in...



    timer = time.time
    t1 = timer()

    pygame.display.flip()
    t2 = timer()

    clock.tick(60)
    t3 = timer()


    print "flip:%s   tick:%s:" % (t2 - t1, t3 - t2)



You can add similar timing parts for the other sections of your game.

Then add some checks like this...

if t2-t1 > 0.002:
    # dump debug information about game state.
    pass




On Mon, Mar 2, 2009 at 11:29 AM, Jake b <ninmonkeys@xxxxxxxxx> wrote:
> Are you re-creating the font surface every frame? Or are you cache-ing the
> .render() output to .blit() ?
>
> On Sat, Feb 28, 2009 at 4:21 PM, Daniel Mateos <daniel@xxxxxxxxx> wrote:
>>
>> Hey again,
>>
>>       3615    0.160    0.000    0.160    0.000 {method 'render' of
>> 'pygame.font.Font' objects}
>>
>> Any help or suggestions for better profileing/tracking down the lag
>> would be good :)
>>
>> --
>> Daniel Mateos
>> http://daniel.mateos.cc
>
>
>
> --
> Jake
>