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

Re: [pygame] timer, update



TNX!! :D

Stephen Anderson wrote:

http://www.python.org/doc/2.3.3/lib/module-time.html

import time
while True:
updateImage()
time.sleep(0.3)

OR

http://www.pygame.org/docs/ref/pygame_time.html

while True:
updateImage()
pygame.time.wait(300)

OR (more accurate, more CPU use)

while True:
updateImage()
pygame.time.delay(300)

OR

http://www.pygame.org/docs/ref/Clock.html

timer = pygame.time.Clock()
fps = 1/3.0
while True:
timer.tick(fps)
updateImage()

OR (if you have other stuff in the loop that takes time)

import time
last = time.time()
while True:
now = time.time()
if (now - last) >= 0.3:
updateImage()
last = now
otherStuff()

OR

last = pygame.time.get_ticks()
while True:
now = pygame.time.get_ticks()
if (now - last) >= 300:
updateImage()
last = now
otherStuff()


Regards,
Steve
On 3 Mar 2004 at 17:20, lorca wrote:


Hi, how can i do that the image update every 300ms, for example:

a = get_time()
while 1:
if get_time() > (a + 300ms)
updateImage()
a = get_time()

i need the methods to get time

PS: sorry for my english