Exemplo n.º 1
0
badGuys = BadGuys("../images", 42)

#Holds the current direction(s) the player is moving.  Set to no movement
#       left-a right-d up-w  down-s
keys = {
    K_a: 0,
    K_d: 0,
    K_w: 0,
    K_s: 0,
}

#Main Game loop.  The game runs for ever.
while gameActive:
    #Fill arena
    arena.Clear()
    player.Move(arena, keys)
    arrows.Move(arena)
    badGuys.MoveAttack(arena, player, arrows)
    player.Blit(arena, pygame.mouse.get_pos())
    arrows.Blit(arena)
    badGuys.Blit(arena)

    #Draw arena
    pygame.display.flip()

    ##Loop over input to see if the keys w, s, a or d were pressed or released
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:  #A key was pressed
            keys[event.key] = player.Speed
        elif event.type == pygame.KEYUP:  #A key was released
Exemplo n.º 2
0
badGuys = BadGuys("../images", 42)
#Holds the current direction(s) the player is moving.  Set to no movement
#       left-a right-d up-w  down-s
keys = {K_a: 0, K_d: 0, K_w: 0, K_s: 0, K_f: 0, K_ESCAPE: 0}

arena.StartGame()

#Main Game loop.  The game runs for ever.
while not arena.Status.TimeUp() and player.Alive() and gameActive:
    #Move the player, arrows and bad guys
    player.Move(arena, keys)
    arrows.Move(arena)
    badGuys.MoveAttack(arena, player, arrows)
    arena.Update(keys, player)
    #Fill arena (surface)
    arena.Clear(player)
    player.Blit(arena, pygame.mouse.get_pos())
    arrows.Blit(arena)
    badGuys.Blit(arena)

    #Draw arena (surface)
    pygame.display.flip()

    ##Loop over input to see if the keys w, s, a or d were pressed or released
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:  #A key was pressed
            keys[event.key] = player.Speed
        elif event.type == pygame.KEYUP:  #A key was released
            keys[event.key] = 0
        elif event.type == pygame.MOUSEBUTTONDOWN:  #The mouse button was clicked
            arrows.AddArrow(pygame.mouse.get_pos(), player)