def playGame(character1, character2): pygame.init() pygame.mixer.init() pygame.mixer.music.load("Sound/07 - The Raising Fighting Spirit.ogg") #Background music "The Rising Fighting Spirit":http://downloads.khinsider.com/game-soundtracks/album/naruto-original-soundtrack-1 pygame.mixer.music.play(-1) displaysurf = pygame.display.set_mode((WIDTH, HEIGHT)) clock = pygame.time.Clock() player1=Character(PLAYER1_CONTROLS, IMAGES[character1], SOUNDS[character1], PLAYER1_POSITION) player2=Character(PLAYER2_CONTROLS, IMAGES[character2], SOUNDS[character2], PLAYER2_POSITION) HUD1_IMAGES=HUD_IMAGES.copy() HUD1_IMAGES["icon"]=IMAGES[character1]["icon"] HUD2_IMAGES=HUD_IMAGES.copy() HUD2_IMAGES["icon"]=IMAGES[character2]["icon"] player1_hud=Hud(HUD1_IMAGES, LEFT_HUD_POSITION) player2_hud=Hud(HUD2_IMAGES, RIGHT_HUD_POSITION) player2_hud.flip() background=load_image("Background/training_background.png") #http://spritedatabase.net/game/1889 background=pygame.transform.scale(background, (WIDTH, HEIGHT)) player1_wins=load_image("Background/player1wins.png") #Used the folowing website to generate the win signs: http://www.dafont.com/ninja-naruto.font player2_wins=load_image("Background/player2wins.png") pygame.display.set_caption('Pybrawl') game_over=False while True: # main game loop displaysurf.blit(background, (0,0)) clock.tick(FPS) for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() elif event.type == KEYDOWN and event.key == K_RETURN and game_over: return if player1.health==0: game_over=True pygame.mixer.music.stop() displaysurf.blit(player2_wins, (172, 200)) if player2.health==0: game_over=True pygame.mixer.music.stop() displaysurf.blit(player1_wins, (172, 200)) keys_status=pygame.key.get_pressed() if game_over: keys_status=[False for i in keys_status] player1.update(keys_status) player2.update(keys_status) collide(player1, player2) keep_inside(player1) keep_inside(player2) if player1.rect.centerx < player2.rect.centerx: player1.direction="right" player2.direction="left" else: player1.direction="left" player2.direction="right" player1_hud.update(player1.health/player1.max_health, player1.mana/player1.max_mana) player2_hud.update(player2.health/player2.max_health, player2.mana/player2.max_mana) player1.draw(displaysurf) player2.draw(displaysurf) player1_hud.draw(displaysurf) player2_hud.draw(displaysurf) pygame.display.update()