I am making a pygame reaction speed game for a project for computer science in which there is a menu, a maingame and a postgame appraisal with a score and an option to try again. I decided to seperate the three parts of the game into three different python scripts, menu, maingame and postgame. The problem comes when switching between the three scripts, as the intention is to get the code to use the same window and switch seamlessly between, where the actual result is a new window opening. Wondering if anyone has any solutions or a different command to try?
I have used the os.system function in conjunction with the three different python scripts.
Here is an image of the problem, https://i.gyazo.com/ddd4615871b26cf0f34257adb12ce618.png
Here is an example of the menu button which when clicked starts the new script.
'''python def MenuButton(surf, cursor_pos, pressed, rect, color): pygame.draw.rect(surf, color, rect) if rect.collidepoint(cursor_pos) and pressed: os.system("maingame.py") '''
Expected output is the seamless switching of scripts, and the game to stay within one window.