random monster images and stats added (monsters, knights)

This commit is contained in:
AleksandraMuczynska 2022-03-24 21:45:17 +01:00
parent 65afafb642
commit d6c281c814
6 changed files with 40 additions and 6 deletions

View File

@ -87,6 +87,7 @@ class Game:
stats = Stats() stats = Stats()
logs = Logs() logs = Logs()
knights_sprite_group = pygame.sprite.Group() knights_sprite_group = pygame.sprite.Group()
monsters_sprite_group = pygame.sprite.Group() monsters_sprite_group = pygame.sprite.Group()
castle_sprite_group = pygame.sprite.Group() castle_sprite_group = pygame.sprite.Group()

View File

@ -9,7 +9,10 @@ class Knight(pygame.sprite.Sprite):
self.image = pygame.transform.scale(self.image, (40, 40)) self.image = pygame.transform.scale(self.image, (40, 40))
self.images.append(self.image) self.images.append(self.image)
self.rect = self.image.get_rect() self.rect = self.image.get_rect()
self.health = random.randrange(7, 12)
self.attack = random.randrange(3, 7) self.health = random.randint(7, 12)
self.attack = random.randint(4, 7)
self.defense = random.randint(1,4)
self.points = 1
knights_list = pygame.sprite.Group() knights_list = pygame.sprite.Group()

View File

@ -3,15 +3,45 @@ import random
class Monster(pygame.sprite.Sprite): class Monster(pygame.sprite.Sprite):
images = [] monster_images = []
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.image = pygame.image.load("./resources/textures/dragon2.png") self.monster_image1 = pygame.image.load("./resources/textures/dragon2.png")
self.image = pygame.transform.scale(self.image, (40, 40)) self.monster_image1 = pygame.transform.scale(self.monster_image1, (40, 40))
self.images.append(self.image) 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() self.rect = self.image.get_rect()
monster_list = pygame.sprite.Group() monster_list = pygame.sprite.Group()
self.health = random.randrange(15, 25) self.health = random.randrange(15, 25)
self.attack = random.randrange(2, 10) 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

BIN
resources/textures/birb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB