def draw(self, window): x = self.pos[0] - self.half_len y = self.pos[1] + self.width p = coords((x, y)) w = dist(self.width) h = dist(self.half_len * 2) r = pygame.Rect(p, (h, w)) pygame.draw.rect(window, self.color, r) xy1 = (self.pos[0] - self.half_len, self.pos[1]) xy2 = (self.pos[0] + self.half_len, self.pos[1]) pygame.draw.line(window, (255, 255, 255), coords(xy1), coords(xy2), 2)
def current_image(self): index = int( self.__alive / self.__duration * self.__count__ ) if index >= self.__count__: index = self.__count__ - 1 r = index // self.__cols__ c = index % self.__cols__ # остаток от деления x = self.__size__*c y = self.__size__*r rect = pygame.Rect( (x,y), (self.__size__,self.__size__) ) im = self.__image.subsurface( rect ) w = dist(self.__width) # Тут надо сжать картинку до нужного размера return pygame.transform.smoothscale(im, (w,w))
def load_image(self): im = pygame.image.load(self.__filepath) d = dist(self.radius * 2) self.__image = pygame.transform.smoothscale(im, (d, d))
def load_image(self): im = pygame.image.load(self.__filepath) w = dist(self.length * 2) h = w * im.get_height() // im.get_width() self.__image = pygame.transform.smoothscale(im, (w, h))
def draw(self, window): xy1 = coords(self.pos) xy2 = coords(self.end) pygame.draw.line(window, self.__color, xy1, xy2, dist(self.__width))
def draw(self, window): win_pos = coords(self.__pos) win_rad = dist(self.__radius) pygame.draw.circle(window, self.__color, win_pos, win_rad)