def display_highscore(n, h): if n: new_message = "NEW HIGH SCORE!" new_txt = media.pixel_font(30).render(new_message, True, white) screen.blit(new_txt, (window_width / 2 - 245, window_height / 3 - 90)) highscore_msg = "Highscore " + str(h) highscore_txt = media.pixel_font(40).render(highscore_msg, True, white) screen.blit(highscore_txt, (window_width / 3 - 40, window_height / 2 - 100))
def display_current_color(c): current_msg = "Safe Color:" current_txt = media.pixel_font(30).render(current_msg, True, white) screen.blit(current_txt, (650, 10)) t = ' ' cc = (0, 0, 0) if c == 0: t = 'RED' cc = red elif c == 1: t = 'BLUE' cc = blue elif c == 2: t = 'GREEN' cc = green elif c == 3: t = 'YELLOW' cc = yellow elif c == 4: t = 'PURPLE' cc = purple color_txt = media.pixel_font(30).render(t, True, cc) screen.blit(color_txt, (1000, 10))
def game_over(s, n, h): gg = True while gg: for event in pygame.event.get(): if event.type == pygame.QUIT: gg = False pygame.quit() if event.type == pygame.MOUSEBUTTONDOWN: gg = False screen.fill(black) asteroid() rocket(False) explosion() display_score(s) display_highscore(n, h) game_over_msg = "GAME OVER" game_over_txt = media.pixel_font(100).render(game_over_msg, True, white) screen.blit(game_over_txt, (window_width / 8 - 10, window_height / 2 - 20)) cont = "Click anywhere to continue" cont_txt = media.pixel_font(18).render(cont, True, white) screen.blit(cont_txt, (window_width / 3 - 40, window_height / 2 + 75)) pygame.display.update()
def display_score(s): button_score = "Score: " + str(s) score_txt = media.pixel_font(50).render(button_score, True, white) screen.blit(score_txt, (5, 5))
def main_menu(s, m): m_on = m s_on = s if m_on: pygame.mixer.music.unpause() button_music = pygame.Rect(180, 9, 28, 28) button_sound = pygame.Rect(180, 50, 28, 28) mm = True while mm: for event in pygame.event.get(): mx, my = pygame.mouse.get_pos() if event.type == pygame.QUIT: mm = False pygame.quit() if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1: if button_music.collidepoint(mx, my): if m_on: m_on = False if s_on: media.click_sound().play() pygame.mixer.music.pause() else: m_on = True if s_on: media.click_sound().play() pygame.mixer.music.unpause() elif button_sound.collidepoint(mx, my): if s_on: s_on = False else: s_on = True media.click_sound().play() else: if s_on: media.click_sound().play() return False, s_on, m_on screen.fill(black) title = "COLOR DODGE" music_title = "Music Off:" sounds_title = "Sounds Off:" play_title = "Click anywhere to play!" title_txt = media.pixel_font(100).render(title, True, white) music_txt = media.pixel_font(15).render(music_title, True, white) sounds_txt = media.pixel_font(15).render(sounds_title, True, white) play_txt = media.pixel_font(18).render(play_title, True, white) screen.blit(title_txt, (window_width / 20 - 10, window_height / 2 - 100)) screen.blit(music_txt, (7, 20)) screen.blit(sounds_txt, (5, 55)) screen.blit(play_txt, (window_width / 3 - 40, window_height / 2 + 30)) if m_on: pygame.draw.rect(screen, white, button_music, 2) else: pygame.draw.rect(screen, white, button_music) if s_on: pygame.draw.rect(screen, white, button_sound, 2) else: pygame.draw.rect(screen, white, button_sound) rocket(False) pygame.display.update() return False