예제 #1
0
 def enemy_lives(self):
     arena = Arena((100, 100))
     bubble = Bubble(arena, (47, 0), 0)
     enemy = Enemy((50, 0), arena)
     lives0 = enemy.lives()
     enemy.go_left()
     enemy.move()
     enemy.collide(bubble)
     self.assertTrue(enemy.lives() == lives0())
예제 #2
0
 def enemy_collide_bubble(self):
     arena = Arena((100, 100))
     bubble = Bubble(arena, (47, 0), 0)
     enemy = Enemy((50, 0), arena)
     enemy.go_left()
     enemy.move()
     enemy.collide(bubble)
     bubble.go_left()
     bubble.move()
     self.assertTrue(enemy.position() == bubble.position())
예제 #3
0
 def dragon_collide_enemy(self):
     arena = Arena((100, 100))
     dragon = Dragon(arena, (50, 0))
     enemy = Enemy((47, 0), arena)
     dragon.go_left()
     dragon.move()
     dragon.collide(enemy)
     self.assertTrue(dragon.lives() == 2)
    def __init__(self):
        self._arena = Arena((W, H))
        self._platform = []
        self._bubble = []
        self._bonus = []
        self._enemy = []
        self._playtime = PLAY_TIME  # seconds

        global TOTAL_POINTS

        with open("platform.txt") as f:
            for line in f:
                x, y, w, h = line.split(",")
                self._platform.append(
                    Platform(self._arena, (int(x), int(y)), int(w), int(h)))
            f.close()

        with open("dragon.txt") as f:
            line = f.readline()
            x, y = line.split(",")
            self._dragon = Dragon(self._arena, (int(x), int(y)))
            line = f.readline()
            x, y = line.split(",")
            self._dragon1 = Dragon(self._arena, (int(x), int(y)))
            f.close()

        with open("enemy.txt") as f:
            for line in f:
                x, y = line.split(",")
                self._enemy.append(Enemy((int(x), int(y)), self._arena))
            f.close()

        with open("bonus.txt") as f:
            for line in f:
                x, y = line.split(",")
                self._bonus.append(Bonus(self._arena, (int(x), int(y))))
                TOTAL_POINTS += 5
            f.close()
예제 #5
0
 def enemy_move_up(self):
     arena = Arena((100, 100))
     enemy = Enemy((50, 50), arena)
     enemy.go_up()
     enemy.move()
     self.assertTrue(enemy.position() == (50, 0, 20, 20))