コード例 #1
0
    def buildGraph(self, fileName):
        """
        Reads the file provided. Parses information.
        Add all vertexes for graph. Key can be Cow and PaintBall object based on information parsed.
        After all vertexes are added, connectGraph() is called to created edges.
        :param fileName:
                containing information about name, location of Cow and name, location, blas radius of
                Paint Ball
        :return: None
        """
        with open(fileName) as f:
            for line in f:
                line = line.strip()
                words = line.split()
                if words[0] == "cow":
                    self.graph.addVertex(Cow(words[1], words[2], words[3]))
                else:
                    self.graph.addVertex(
                        PaintBall(words[1], words[2], words[3], words[4]))

        self.connectGraph()
        pass
コード例 #2
0
        pygame.display.update()


pygame.time.set_timer(pygame.USEREVENT + 1, 4700)
pygame.time.set_timer(pygame.USEREVENT + 3, 20000)

vel = 5

# game loop
running = True
while running:

    pygame.time.delay(100)
    screen.blit(imagemfundo, (0, 0))

    c1 = Cow(800, 280, pygame.image.load('cow.png'), 1)
    u1 = Ufo(800, 280, pygame.image.load('sci-fi.png'), 1)
    d1 = Dino(800, 280, pygame.image.load('dinosaur2.png'), 1)

    c2 = Cow(800, 340, pygame.image.load('cow.png'), 2)
    u2 = Ufo(800, 340, pygame.image.load('sci-fi.png'), 2)
    d2 = Dino(800, 340, pygame.image.load('dinosaur2.png'), 2)

    for o in obstaculos:
        screen.blit(o.img, (o.x, o.y))
        if player.linha == o.linha:
            if player.x + 120 >= o.x >= 150:
                gameover()
        o.x -= vel
        if o.x <= -64:
            obstaculos.pop(obstaculos.index(o))