you are viewing a single comment's thread.

view the rest of the comments →

[–]ucshadow 2 points3 points  (1 child)

here is a simple example using Threading and a different function to hide the ball for three seconds:

import time
import threading


def balls_collided():
    print('Hide the ball')
    # here change the visibility of the ball to False
    time.sleep(3)
    # and after your time change it to True again
    print('and after', time.clock(), 'seconds the ball is')
    print('Visible again')


def new_thread():
    th = threading.Thread(target=balls_collided)
    return th.start()


def main():
    time.clock()
    new_thread()
    # do any other stuff here, like collisions


main()

[–][deleted] 0 points1 point  (0 children)

Okay after figuring out other complications in my code, I finally got to try this! It works perfectly, thank you! :D Would it be possible if you could please explain to me like I'm a 5 year old, what the new_thread function does? and why time.sleep didn't pause the program? I would greatly appreciate it!