def reload(self, fileName, x, y, z, rotate, scale): filePath = _rootDir + '/' + fileName import game.gameWindow as gameWindow scene = gameWindow.getScene() prevRect = copy(self.rect) if self.fileName is None or self.fileName != fileName or rotate != 0 or scale != 1: self.fileName = fileName self.image = pygame.image.load(filePath).convert_alpha(scene) self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y if rotate != 0 or scale != 1: self.image = pygame.transform.rotozoom(self.image, rotate, scale) transformedRect = self.image.get_rect() transformedRect.center = self.rect.center self.rect = transformedRect if prevRect is not None: rectToUpdate = Rect(prevRect.x - 1, prevRect.y - 1, prevRect.width + 2, prevRect.height + 2) r2 = Rect(self.rect.x - 1, self.rect.y - 1, self.rect.width + 2, self.rect.height + 2) rectToUpdate.union_ip(r2) addRectToUpdate(rectToUpdate) else: rectToUpdate = Rect(self.rect.x - 1, self.rect.y - 1, self.rect.width + 2, self.rect.height + 2) addRectToUpdate(rectToUpdate) if self.z is not None: self.remove() _spritesList[z].add(self) self.z = z
def reload(self, x, y, w, h, z, width, colorName): if self.x is not None: rectToUpdate = Rect(self.x - self.w / 2 - 1, self.y - self.h / 2 - 1, self.w + 2, self.h + 2) r2 = Rect(x - w / 2 - 1, y - h / 2 - 1, w + 2, h + 2) rectToUpdate.union_ip(r2) addRectToUpdate(rectToUpdate) else: rectToUpdate = Rect(x - w / 2 - 1, y - h / 2 - 1, w + 2, h + 2) addRectToUpdate(rectToUpdate) self.x = x self.y = y self.w = w self.h = h self.width = width self.colorName = colorName if self.z is not None: self.remove() _ovalsList[z].append(self) self.z = z
def reload(self, text, x, y, z, colorName, fontName, fontSize): prevRect = None if self.label is not None: prevRect = self.label.get_rect() self.text = text prevX = self.x prevY = self.y self.x = x self.y = y self.colorName = colorName fontName = _rootDir + '/' + fontName self.fontName = fontName self.fontSize = fontSize try: labelFont = pygame.font.Font(fontName, fontSize) except IOError: labelFont = pygame.font.SysFont('', fontSize) self.label = labelFont.render(text, True, Color('#' + self.colorName)) rect = self.label.get_rect() if prevRect is not None: rectToUpdate = Rect(prevX - prevRect.width / 2 - 1, prevY - prevRect.height / 2 - 1, prevRect.width + 2, prevRect.height + 2) r2 = Rect(x - rect.width / 2 - 1, y - rect.height / 2 - 1, rect.width + 2, rect.height + 2) rectToUpdate.union_ip(r2) addRectToUpdate(rectToUpdate) else: rectToUpdate = Rect(x - rect.width / 2 - 1, y - rect.height / 2 - 1, rect.width + 2, rect.height + 2) addRectToUpdate(rectToUpdate) if self.z is not None: self.remove() _textsList[z].append(self) self.z = z