(
self,
background,
bird,
score_function=None,
*screen_geometry,
fp=("tube.png", "tube_mourth"),
animation_speed=50,
)
| 17 | __pastTubes = [] |
| 18 | |
| 19 | def __init__( |
| 20 | self, |
| 21 | background, |
| 22 | bird, |
| 23 | score_function=None, |
| 24 | *screen_geometry, |
| 25 | fp=("tube.png", "tube_mourth"), |
| 26 | animation_speed=50, |
| 27 | ): |
| 28 | # Verifica os parâmetros passados e lança um erro caso algo esteja incorreto |
| 29 | if not isinstance(background, Background): |
| 30 | raise TypeError( |
| 31 | "The background argument must be an instance of Background." |
| 32 | ) |
| 33 | if not len(fp) == 2: |
| 34 | raise TypeError( |
| 35 | "The parameter fp should be a sequence containing the path of the images of the tube body and the tube mouth." |
| 36 | ) |
| 37 | if not isinstance(bird, Bird): |
| 38 | raise TypeError("The birdargument must be an instance of Bird.") |
| 39 | if not callable(score_function): |
| 40 | raise TypeError("The score_function argument must be a callable object.") |
| 41 | |
| 42 | Thread.__init__(self) |
| 43 | |
| 44 | # Instância os parâmetros |
| 45 | self.__background = background |
| 46 | self.image_path = fp |
| 47 | self.__animation_speed = animation_speed |
| 48 | self.__score_method = score_function |
| 49 | |
| 50 | # Recebe a largura e altura do background |
| 51 | self.__width = screen_geometry[0] |
| 52 | self.__height = screen_geometry[1] |
| 53 | |
| 54 | # Recebe o tamanho do pássaro |
| 55 | self.__bird_w = bird.width |
| 56 | self.__bird_h = bird.height |
| 57 | |
| 58 | # Calcula a largura e altura da imagem |
| 59 | self.__imageWidth = (self.__width // 100) * 10 |
| 60 | self.__imageHeight = (self.__height // 100) * 5 |
| 61 | |
| 62 | # Cria uma lista para guardar imagens dos tubos |
| 63 | try: |
| 64 | self.deleteAll() |
| 65 | except BaseException: |
| 66 | self.__background.tubeImages = [] |
| 67 | |
| 68 | # Cria uma lista somente para guardar as imagens futuras dos corpos dos tubos gerados |
| 69 | self.__background.tubeImages.append([]) |
| 70 | |
| 71 | # Carrega a imagem da boca do tubo |
| 72 | self.__background.tubeImages.append( |
| 73 | self.getPhotoImage( |
| 74 | image_path=self.image_path[1], |
| 75 | width=self.__imageWidth, |
| 76 | height=self.__imageHeight, |
nothing calls this directly
no test coverage detected