예제 #1
0
파일: movement.py 프로젝트: mirtimoha/Pyman
# Goes through the entire map and outlines which 16x16 areas are black
# This identifies where Pacman and Pellets can and cannot go
x = 0
y = 16
while y < WINDOWHEIGHT:
    while x < WINDOWWIDTH:
        # 16x16 area used for cropping
        selected_area = pygame.Rect(x, y, 16, 16)

        # Creates a cropped image from the background
        cropped_image = background.subsurface(selected_area)

        # If the cropped image's color is BLACK
        if pygame.transform.average_color(cropped_image)[:3] == BLACK:
            grid_member = Box(x, y, GREEN)
            grid_member.check_possible_moves(x, y)
            grid_group.add(grid_member)
        else:
            box_group.add(Box(x, y, RED))

        x += 16
    y += 16
    x = 0

# Initialize Pacman
pacman = Pacman(224, 384, MOVESPEED, box_group)  # 16 * 14, 16 * 24
pacman_group = pygame.sprite.GroupSingle(pacman)

# Initialize movement variable
movement = 'R'
last_movement = 'R'