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

[pygame] Problem clock.tick() and Threads



Hi,

I'm developping a Racing Top View Game (pyRacerz) and I want to add a
Network Game Feature.

To do that, I've created 2 Threads: 1 to receive datas and 1 to send.

On my main Loop I use:
clock.tick(100)
To limit the FPS (but I update the Frame 1 time on 2)

The problem is, when I use "clock.tick(100)", the Threads don't run,
because I think, there's not enough CPU.

If I substitute "clock.tick(100)" by "pygame.time.wait(10)", the
Threads work well...

But I want a precise FPS to have a smooth and playable game.

The problem comes, I think, from the pygame.time.delay" function which
is surely used by the clock.tick(100), and which consumes a high
amount of CPU.

Do you have an idea on how I can solve my problem ?

(Perhaps twisted will solve the problem, but I don't wanttoo much dependencies)

Thanks in advance,
Jujucece