import pygame from pygame.locals import * import sys import time pygame.init() screen = pygame.display.set_mode( ( 400, 300 ) ) background = pygame.Surface((400, 300)) displaysurface = pygame.display.set_mode((400,600)) surface = pygame.Surface(( 10, 10)) surface.fill((0,255,0)) display = pygame.display.set_mode((300, 300)) FPS_CLOCK = pygame.time.Clock() pygame.mixer.music.load('background.wav') #Collision detection code if pygame.spritecollideany( P1, enemies): DISPLAYSURF.fill(RED) pygame.display.update() for entity in all_sprites : entity.kill() time.sleep(2) pygame.quit() sys.exit() #Drawing shapes pygame.draw.polygon(surface, color, pointlist, width) pygame.draw.line(surface, color, start_point, end_point, width) pygame.draw.lines(surface, color, closed, pointlist, width) pygame.draw.circle(surface, color, center_point, radius, width) pygame.draw.ellipse(surface, color, bounding_rectangle, width) pygame.draw.rect(surface, color, rectangle_tuple, width) #Fonts dialogue_font = pygame.font.SysFont('arial', 15) name_font = pygame.font.SysFont('Helvetoca', 20) game_over_font = pygame.font.SysFont('Verdana', 60) dialogue = dialogue_font.render("Hey there, Beautiful weather today!", True, (0, 0, 0)) name = name_font.render(" John Hubbard", True, (0,0,255)) game_over = game_over_font.render("Game Over", True, (255,0,0)) screen.blit(dialogue, (40,40)) screen.blit(name, (40,140)) screen.blit(game_over, (40,240)) #Sounds pygame.mixer.music.play(0) pygame.mixer.music.play(5) pygame.mixer.music.play(-1) pygame.mixer.music.queue pygame.mixer.music.stop pygame.mixer.music.pause pygame.mixer.unpause SONG_END_EVENT = pygame.USEREVENT + 1 while True : for event in pygame.event.get() : if event.type == SONG_END : #Code to be excecuted while 1: for event in pygame.event.get() : if event.type == QUIT : pygame.quit() sys.exit() left, middle, right = pygame.mouse.get_pressed() if left : print( "Left mouse key") //... //... pygame.display.update() FPS_CLOCK.tick(30) while True: ... ... for event in pygame.event.get() : if event.type == QUIT : pygame.quit() sys.exit()