Hey everyone! Okay I have another pretty simple problem...

while mainloop == 0:
       for event in pygame.event.get():
          if (event.type == KEYDOWN):
            draw_level()
            if (event.key == K_ESCAPE):
                sys.exit()    
            if (event.key == K_RIGHT):
                while roll == 0:
                    if level[yd][xd + 1] == 1:
                        xd = xd - 1
                        roll = 1
                               blahblahblah.........

The problem is is after each one of my "if" statements are run and the user keeps on hitting various keys, the program remembers each key and in which order and sends a command that it was hit at the next available place........

So pretty much how do I lets say "clear" the keyboard input so the program "forgets" that other keys were hit right after another?

PLEASE RESPOND!!! THANKZ!

I don't really know what you mean by your explanation of what's happening but I presume that you would want to modify your code to use if/else if structures as such:

while mainloop == 0:
       for event in pygame.event.get():
          if event.type == KEYDOWN:
            draw_level()
            if event.key == K_ESCAPE:
                sys.exit()    
            elif event.key == K_RIGHT:
               # perform right action
            elif event.key == K_UP:
               # perform up action
            else:
               #blahblahblah.........

HTH

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.