how can threading in python help me in my traffic simulation project? can i use it to detect other cars?

Threading is used to run two things at once so it could help you if needed a collision detection method to run and to run the cars as well. But personally i think you could do it without threading in pygame, all you would do is use image.rect.colliderect() and that would tell you if it collided with the rect that you provide.

Hope that helps

ive tried to create a traffic light in pygame. ive managed to draw the rectangle and circular part. the upper part is red and lower one green. but nw how do I make it turn green after 5 seconds. can anyone help me plz?

You don't need threading. In your main loop, use the pygame timer functions to tell you how much time has elapsed since the last loop, and when that time accumulates to 5 seconds you may redraw the circle.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.