Hardware Reference
In-Depth Information
When you use multi-threading, you are telling your program to create a new thread (or
piece of string), which has its own commands (knots). This will run at the same time as
your original program, which keeps on running too. Your program is now doing two
things at once, rather than just one (see FigureĀ 9-6).
FIGURE.9-6 When you create multiple threads, your program can do more than
one thing at a time.
To make all the obstacles in the game run at the same time, you need to create a new
thread each time an obstacle is run, meaning that the programs that make the obsta-
cles work are all running at the same time.
Multi-threading is incredibly useful in computer programming, but it is very
advanced and it can get complicated very quickly. If you want to know more
about multi-threading in Python, visit www.tutorialspoint.com/python/python_
multithreading.htm.
Let's return to your wall. To get it running in its own thread, you have to change the
line of the program that calls the theWall() function, and use thread.start_
new_thread() :
1. Delete the last line of the program that runs the theWall() function, which
looks like this:
theWall(arenaPos, WALLZ)
 
Search WWH ::




Custom Search