I have a GAME OVER screen that is functioning when your health is depleted. This GAME OVER screen is executed with the show_go_screen. I tried to just duplicate the method for the show_go_screen into my show_winning() function for the other screen. I rigged this show winning function by setting your health back to normal when going back to the game. However once you have gone to the YOU WIN screen and back to the game you cannot go to the YOU WIN screen again. I have included the code for my player shield below (which determine when there is a GAME OVER/YOUWIN event) I have also included the methods for the show_go_screen (which is for GAME OVER) and the code for show_winning() method (which is for the YOU WIN screen). If someone can tell me how to best modify my code to get the desired result.
if TrumpHits:
self.trump.shield -= 25
if self.trump.shield <= 0:
self.show_winning()
self.winning = True
if hits:
self.player.shield -= 20
if flyby:
self.player.shield -= 30
if self.player.shield <= 0:
self.playing = False
here are the show_go_screen() and the show_winning() methods
def show_go_screen(self):
# game over/continue
if not self.running:
return
bg = pg.image.load("GAMEOVERslimeCOVERAGE.png")
self.screen.blit(bg,(0,0))
self.draw_text("Press space bar to play again", 22, WHITE, WIDTH / 2, HEIGHT * 7 / 8)
HEIGHT / 2 + 40)
pg.display.flip()
waiting = True
while waiting:
self.clock.tick(FPS)
for event in pg.event.get():
if event.type == pg.QUIT:
waiting = False
self.running = False
if event.type == pg.KEYDOWN:
if event.key == pg.K_SPACE:
waiting = False
self.PlayMusic()
def show_winning(self):
# game over/continue
if self.winning:
return
bg = pg.image.load("TRUMPyouwin3d.png")
self.screen.blit(bg,(0,0))
self.draw_text("Press any key to play again", 22, WHITE, WIDTH / 2, HEIGHT * 7 / 8)
pg.display.flip()
waiting = True
while waiting:
self.clock.tick(FPS)
for event in pg.event.get():
if event.type == pg.QUIT:
waiting = False
self.running = False
if event.type == pg.KEYDOWN:
if event.key == pg.K_SPACE:
waiting = False
self.PlayMusic()
self.player.shield = 100
self.trump.shield = 100
def wait_for_key(self):
waiting = True
while waiting:
self.clock.tick(FPS)
for event in pg.event.get():
if event.type == pg.QUIT:
waiting = False
self.running = False
if event.type == pg.KEYUP:
waiting = False