37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
import pygame.image
|
|
import random
|
|
|
|
monster_images = [
|
|
pygame.image.load("./resources/textures/dragon2.png"),
|
|
pygame.image.load("./resources/textures/birb.png"),
|
|
pygame.image.load("./resources/textures/wolfart.png"),
|
|
pygame.image.load("./resources/textures/goblin.png"),
|
|
]
|
|
|
|
|
|
class Monster(pygame.sprite.Sprite):
|
|
def __init__(self, position, group):
|
|
super().__init__(group)
|
|
self.image = random.choice(monster_images)
|
|
self.image = pygame.transform.scale(self.image, (40, 40))
|
|
self.rect = self.image.get_rect(topleft=position)
|
|
|
|
self.health = random.randrange(15, 25)
|
|
self.attack = random.randrange(2, 10)
|
|
if self.image == monster_images[0]:
|
|
self.health = 20
|
|
self.attack = 9
|
|
self.points = 10
|
|
elif self.image == monster_images[1]:
|
|
self.health = 15
|
|
self.attack = 7
|
|
self.points = 7
|
|
elif self.image == monster_images[2]:
|
|
self.health = 10
|
|
self.attack = 4
|
|
self.points = 4
|
|
elif self.image == monster_images[3]:
|
|
self.health = 7
|
|
self.attack = 2
|
|
self.points = 2
|