I am very new to python and pygame and I'm currently making a very basic experiment with it. So far, I know how to draw an image on the screen, move it around, add a background, stuff like that. But what I have always been wondering is, how do I switch between screens in a game and how do I keep the code tidy when doing so?
Every time I try to add a new thing to my already unstable code, it takes only a few lines to break it and it becomes a confusing mess.
If for example, I want a start screen that shows the title and a "press any key to continue" kinda thing, how do I do it?
Asked
Active
Viewed 86 times
0
-
[Here's](https://stackoverflow.com/questions/59678318/how-can-i-make-my-sprite-launch-an-object-towards-the-mouse-position/59681310#59681310) an example – sloth Mar 16 '21 at 11:57
-
Or [here](https://stackoverflow.com/questions/18693224/trying-to-figure-out-how-to-track-pygame-events-and-organize-the-games-function/18693749#18693749) or [here](https://stackoverflow.com/questions/14700889/pygame-level-menu-states/14727074#14727074) or [here](https://stackoverflow.com/questions/59726334/how-to-ask-20-multiple-choice-questions-on-pygame/59729471#59729471) – sloth Mar 16 '21 at 12:05
1 Answers
0
A quick fix:
- Make the entire screen white and then draw the second screen onto the first one.
- Then when you need the other screen, just refill the screen with black and then continue.
- This can be achieved by putting the screens in their own separate functions.
Let me know if this helps out
Virej Dasani
- 185
- 2
- 13