def runmultibattle(SCREEN, ImagesPlayer, ImagesEnemy,
DISPLAYSURF, FPSCLOCK, FPS, titlescreen):
# 1v1 battle multiplayer mode
# Group for drawing all sprites
rendergroup = pygame.sprite.RenderPlain()
wall_list = utils.createwalls(SCREEN, rendergroup)
# Initiate player1
player_list = pygame.sprite.Group()
enemy_list = pygame.sprite.Group()
Marcus = characters.Player('Marcus', ImagesPlayer, SCREEN, rendergroup,
wall_list, player_list, enemy_list)
# initiating bullet sprite groups
friendly_bullet_list = pygame.sprite.Group()
enemy_bullet_list = pygame.sprite.Group()
Cole = characters.Player2('Cole', ImagesPlayer, SCREEN, rendergroup,
wall_list, player_list, enemy_list, True)
while not Marcus.dead and not Cole.dead: # main game loop
for event in pygame.event.get(): # event handling loop
if event.type == pygame.locals.QUIT:
terminate()
elif event.type == pygame.locals.KEYDOWN and \
event.key == pygame.locals.K_ESCAPE:
newmode = showPauseScreen(titlescreen)
if newmode != 'no changes':
global runGame
runGame = newmode
return 2
elif event.type == pygame.locals.KEYDOWN and \
event.key == pygame.locals.K_r:
Marcus.reload()
elif event.type == pygame.locals.KEYDOWN and \
event.key == pygame.locals.K_k:
Cole.reload()
elif event.type == pygame.locals.KEYDOWN and \
event.key == pygame.locals.K_l:
Cole.shoot(enemy_bullet_list, rendergroup)
elif event.type == pygame.locals.KEYDOWN:
Marcus.update_position(event.key)
Cole.update_position(event.key)
elif event.type == pygame.locals.MOUSEBUTTONDOWN:
Marcus.shoot(friendly_bullet_list, rendergroup)
player_list.update()
enemy_list.update()
for i in range(10):
friendly_bullet_list.update(enemy_list, wall_list)
enemy_bullet_list.update(player_list, wall_list)
DISPLAYSURF.fill(BACKGROUND)
rendergroup.draw(DISPLAYSURF)
pygame.display.update()
FPSCLOCK.tick(FPS)
return int(Marcus.dead)
评论列表
文章目录