how to make objects move using wasd controls in pygame

Solutions on MaxInterview for how to make objects move using wasd controls in pygame by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "how to make objects move using wasd controls in pygame"
Noah
26 Mar 2018
1running = True
2while running:
3    for event in pygame.event.get():
4        if event.type == pygame.QUIT:
5            pygame.quit(); sys.exit()
6            running = False
7
8        if event.type == pygame.KEYDOWN:
9            if event.key == pygame.K_LEFT:
10                print('left')
11            if event.key == pygame.K_RIGHT:
12                print('right')
13            if event.key == pygame.K_UP:
14            	print('up')
15            if event.key == pygame.K_DOWN:
16              print('down')  
17              
18