import pygame.image import random class Monster(pygame.sprite.Sprite): monster_images = [] def __init__(self): super().__init__() self.monster_image1 = pygame.image.load("./resources/textures/dragon2.png") self.monster_image1 = pygame.transform.scale(self.monster_image1, (40, 40)) self.monster_image2 = pygame.image.load("./resources/textures/birb.png") self.monster_image2 = pygame.transform.scale(self.monster_image2, (40, 40)) self.monster_image3 = pygame.image.load("./resources/textures/wolfart.png") self.monster_image3 = pygame.transform.scale(self.monster_image3, (40, 40)) self.monster_image4 = pygame.image.load("./resources/textures/goblin.png") self.monster_image4 = pygame.transform.scale(self.monster_image4, (40, 40)) self.monster_images.append(self.monster_image1) self.monster_images.append(self.monster_image2) self.monster_images.append(self.monster_image3) self.monster_images.append(self.monster_image4) #self.images.append(self.image1) self.image = random.choice(self.monster_images) self.rect = self.image.get_rect() monster_list = pygame.sprite.Group() self.health = random.randrange(15, 25) self.attack = random.randrange(2, 10) if self.image == self.monster_images[0]: self.health = 20 self.attack = 9 self.points = 10 elif self.image == self.monster_images[1]: self.health = 15 self.attack = 7 self.points = 7 elif self.image == self.monster_images[2]: self.health = 10 self.attack = 4 self.points = 4 elif self.image == self.monster_images[3]: self.health = 7 self.attack = 2 self.points = 2