Exemplo n.º 1
0
def draw_game(screen, bird, pipes):
    if bird:
        pygame.draw.rect(screen, BLUE, bird, 2)
        pygame.draw.rect(screen, WHITE, dilate_rect(bird, DILATE_COLLISION), 2 )

    for pipe in pipes:
        pygame.draw.rect(screen, GREEN, pipe, 2)
        pygame.draw.rect(screen, RED, [pipe[0], 1, pipe[2], pipe[1] - 1], 2)
        pygame.draw.rect(screen, RED, [pipe[0], pipe[1] + pipe[3], pipe[2], FLOOR_Y - pipe[1] - pipe[3]], 2)
    
    pygame.draw.line(screen, RED, (0, FLOOR_Y), (WIDTH - 1, FLOOR_Y))
    pygame.draw.line(screen, WHITE, (0, FLOOR_Y - FLOOR_SECURITY), (WIDTH - 1, FLOOR_Y - FLOOR_SECURITY))
Exemplo n.º 2
0
 def play(self):
     bird = self.bird if self.bird else (self.x - 30, self.y - 30, 60, 60)
     if self.y > (FLOOR_Y - FLOOR_SECURITY):
         self.fly()
     pipe = self.next_pipe()
     if pipe:
         if pipe[1] + pipe[3] < bird[1] + bird[3] - 5: #and self.speed_y >= 0:
             self.fly()
         if rect_collision([pipe[0], pipe[1] + pipe[3], pipe[2], FLOOR_Y - pipe[1] - pipe[3]], dilate_rect(bird, DILATE_COLLISION)):
             self.fly()