pygame - Perform different operations in response to the same event the second time in python
阿神
阿神 2017-05-18 10:58:36
0
2
481

In a loop, the system responds to the pressing of a key on the keyboard, then performs two operations, and then responds to the pressing of the same key on the keyboard again, but only performs the second operation. What should be done?

for event in pygame.event.get():
    if event.type == pygame.KEYDOWN:
        if event.key == pygame.K_ESCAPE:
            sys.exit()
        elif event.key == pygame.K_RIGHT:
            tank.update1()
            tank.moving_right = True

For example, in the elif statement, starting from the second time, only tank.moving_right = True will be executed instead of tank.update1()
How to deal with it

阿神
阿神

闭关修行中......

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!