I want to make a function where when I press p the game stops and shows "Game Paused".
Any help?
I suggest adding a is_paused
boolean flag and add if not is_paused
inside your update
method to act accordingly (The update
method is the method that is executed 30 times per second in your game):
Some pseudocode:
def update(screen, entities, is_paused):
if is_paused:
if is_clicked_button(BUTTON_TO_UNPAUSE):
is_paused = False
return
# Logic on screen, entities and so on...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.