WMICraft/models/monster.py

48 lines
1.8 KiB
Python
Raw Permalink Normal View History

2022-03-10 18:34:58 +01:00
import pygame.image
2022-03-24 12:54:22 +01:00
import random
2022-03-10 18:34:58 +01:00
class Monster(pygame.sprite.Sprite):
monster_images = []
2022-03-10 18:34:58 +01:00
2022-03-24 12:54:22 +01:00
def __init__(self):
2022-03-10 18:34:58 +01:00
super().__init__()
2022-03-24 12:54:22 +01:00
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)
2022-03-10 18:34:58 +01:00
self.rect = self.image.get_rect()
monster_list = pygame.sprite.Group()
2022-03-24 12:54:22 +01:00
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