I'm trying create this function such that if any key besides any of the arrow keys are pressed, the loop continues until an arrow key is pressed. The program crashes every time and doesn't display the error. Any idea why?
def speed(self, key):
# Figure out if it was an arrow key. If so
# adjust speed
n = 'go'
while n == 'go':
if key == pygame.K_LEFT:
x_speed=-5
y_speed=0
return x_speed, y_speed
n = 'stop'
if key == pygame.K_RIGHT:
x_speed = 5
y_speed = 0
return x_speed, y_speed
n = 'stop'
if key == pygame.K_UP:
y_speed = -5
x_speed = 0
return x_speed, y_speed
n = 'stop'
if key == pygame.K_DOWN:
y_speed = 5
x_speed = 0
return x_speed, y_speed
n = 'stop'
else:
continue