WMICraft/models/castle.py

21 lines
809 B
Python
Raw Permalink Normal View History

2022-04-28 14:13:59 +02:00
import random
2022-03-24 16:32:14 +01:00
import pygame.image
2022-04-11 00:01:57 +02:00
from common.helpers import parse_cord
2022-04-28 14:13:59 +02:00
from logic.health_bar import HealthBar
2022-04-11 00:01:57 +02:00
2022-03-24 16:32:14 +01:00
class Castle(pygame.sprite.Sprite):
2022-04-28 14:13:59 +02:00
def __init__(self, screen, position, group):
2022-04-10 20:28:50 +02:00
super().__init__(group)
self._layer = 1
2022-04-10 20:28:50 +02:00
self.image = pygame.image.load("./resources/textures/castle.png").convert_alpha()
2022-03-24 16:32:14 +01:00
self.image = pygame.transform.scale(self.image, (78, 78))
2022-04-11 12:56:22 +02:00
self.position = position
2022-04-11 12:00:15 +02:00
position_in_px = (parse_cord(position[0]), parse_cord(position[1]))
2022-04-11 00:01:57 +02:00
self.rect = self.image.get_rect(center=position_in_px)
2022-04-28 14:13:59 +02:00
self.max_hp = 80
self.current_hp = random.randint(1, self.max_hp)
self.health_bar = HealthBar(screen, self.rect, current_hp=self.current_hp, max_hp=self.max_hp, calculate_xy=True, calculate_size=True)