I have been working on pygame project based on thenewboston tutorials. It is an older series, I have got some errors while packing game loop into function (it references variables that are not global, if you use direction = "right", gameloop() gonna complain about unreferenced variable key = left: direction = "left"), so I decided to leave while loop as it is. My structure is:
while game['intro']:
...
while not game['exit']
...
while game['victory_screen']
message("press R to return to Main Menu")
if key = R: #simplifeid pygame.keydown, k_r.
game['intro'] = True
game['victory_screen'] = False
So instead of returning to intro, game just closes. I get why it is, python sees the end of the code and does not return to previous while loop. Any way to restart the game without closing it? I tired again to use functions, packing intro loop works, main game does not work, looks like functions don't really like while loops inside.