pygame question
Michael Bauers
me at michaelbauers.com
Thu Jul 11 22:32:22 EDT 2002
I borrowed the event loop from pygame's chimp example. And they used 'is'
for some reason. All I did was add the handler for K_r and made it look
like the other code in their loop.
"Terry Reedy" <tjreedy at udel.edu> wrote in message
news:BnqX8.37719$iB1.2146169 at bin4.nnrp.aus1.giganews.com...
>
> "Michael Bauers" <me at michaelbauers.com> wrote in message
> news:uis3ccnreo0u32 at corp.supernews.com...
> > I was curious as to why 'is K_SPACE' worked, but 'is K_r' did not.
> I had to
> > change the test for 'r' to ==.
> >
> > * code snippet *
> > elif (event.type is KEYDOWN and event.key is
> > K_SPACE):
> > # DO SOMETHING
> > elif (event.type is KEYDOWN and
> > event.key == K_r):
> > # DO SOMETHING ELSE
>
> I don't know about your question, but I do about eliminating redundant
> code 8-)
> I would redo as
> elif event.type == KEYDOWN:
> keyhit = event.key
> if keyhit == K_SPACE: #do x
> elif keyhit == K_r: # do y
>
> Should K_r be K_R? What was your error message? (ie, what does 'not
> work' mean?)
>
> Terry J. Reedy
>
>
>
More information about the Python-list
mailing list