'How do I change this recursive approach to iterative approach?
This is a game function from pygame. If user press left (pygame.KEYDOWN.K_LEFT), angle -= 1. Else if user press right (pygame.KEYDOWN.K_RIGHT), angle += 1. 'Event.type' is the detection of which key the user pressed. angle can be negative.
Question: is this a recursive approach? if yes, how to change it to be iterative, or faster efficiency?
angle = 0
if event.type == pygame.KEYDOWN.K_LEFT:
    angle -= 1 
elif event.type == pygame.KEYDOWN.K_RIGHT:
    angle += 1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|
