Game programming and threads problem - 1 attachment

Albert Hofkamp hat at se-126.se.wtb.tue.nl
Mon Mar 8 03:48:24 EST 2004


On Sat, 06 Mar 2004 23:57:53 GMT, westlord <westlord at dev.null.net> wrote:
> Hello.  I have written a game much like the TypingCommand of old.  It is
> a cross between a typing game and missle command.  Words come down from
> the top of the screen and head toward your cities at the bottom. 

Nice idea.

> The problem is that while the thread starts, it does not update.  What
> the thread does depends on the machine I run it on.  Some machines if

Having 1 thread for 1 word feels a bit expensive to me, in addition you
get a number of concurrency problems that you have to deal with.

> you move around the window the game is in, the thread will work, kind
> of.  On other machines, if you hold down a key, the thread will work. 
> So, what's the problem? 

You didn.t mention whether you use operating-system threads or Python
threads, nor what operating system and/or Python versions runs at
different machines.
It sounds to me that you are struggling with operating-system (or
window-system) specific issues.
I don't know enough about threads to help you with this.

> Couple of notes: Yes, I know there's probably a better way of doing
> this but I don't know of one.  If you can educate me, it would be
> appreciated.  Also, I have attached the code to make thing's easier

If I were in your shoes, I would probably drop threading, and go for
having 1 component/thread that handles all words.  (ie it has a list of words
with their position, and after waiting a while, it updates and redraws
all the words).  This may be better managable.

PS I don't know what graphic system you use, but pygame may be useful to
   you.

Albert



More information about the Python-list mailing list