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

[pygame] Question about timing



Sorry if my question is silly, but maybe I didn't catch very much some question about pygame.time module.

I am writing an application which needs to very accurate about timing; it displays sequentially some images, each one of them remaining on the screen for a constant time T.
This is a part of the code I wrote to understand how time module works:

*********************************************************************
clock = time.Clock()

while 1:
   
    clock.tick
    msec = clock.get_time()
    print "1. msec = %i" %msec  # these lines has been written just to see what is returned by get_time()
   
    for event in pygame.event.get():
        if event.type == QUIT:
            exit()
           
    surf.fill((255,255,255,255))  # these lines has been written just to see what is returned by get_time()

msec = clock.get_time()
    print "2. msec = %i" %msec
*********************************************************************

This is the output of th application:

1.msec = 1767859565
2.msec = 1767859565
1.msec = 1767859565
2.msec = 1767859565
1.msec = 1767859565
2.msec = 1767859565
....

My problem is that I cannot understand what type is returned by get.time():

at http://snipurl.com/28h08, it is reported that this method returns an int
at http://snipurl.com/28h0t , it is reported that this method returns milliseconds.

My other question is: is it possibile to transform milliseconds type into an int?

I am using Pygame 1.7.1

Thank you in advance for any help you can provide me,
Francesco