2021-03-30 11:24:50 +02:00
|
|
|
import pygame
|
|
|
|
|
|
|
|
from config import *
|
|
|
|
|
|
|
|
|
|
|
|
class BaseField:
|
|
|
|
def __init__(self, img_path: str):
|
|
|
|
self._img_path = img_path
|
|
|
|
|
2021-04-11 19:48:44 +02:00
|
|
|
def draw_field(self, screen: pygame.Surface, pos_x: int, pos_y: int,
|
|
|
|
is_centered: bool = False, size: tuple = None, angle: float = 0.0):
|
2021-03-30 11:24:50 +02:00
|
|
|
img = pygame.image.load(self._img_path)
|
2021-04-11 19:48:44 +02:00
|
|
|
img = pygame.transform.rotate(img, angle)
|
|
|
|
|
2021-04-13 10:40:56 +02:00
|
|
|
# def draw_field(self, screen: pygame.Surface, pos_x: int, pos_y: int, is_centered: bool = False, size: tuple = None,
|
|
|
|
# angle: int = 0):
|
|
|
|
# pre_img = pygame.image.load(self._img_path)
|
|
|
|
# if angle == 90:
|
|
|
|
# pre_img = pygame.transform.flip(pre_img, True, False)
|
|
|
|
# img = pygame.transform.rotate(pre_img, angle)
|
2021-03-30 11:24:50 +02:00
|
|
|
scale = pygame.transform.scale(img, (FIELD_SIZE, FIELD_SIZE))
|
|
|
|
rect = img.get_rect()
|
2021-04-11 19:48:44 +02:00
|
|
|
|
2021-03-30 11:24:50 +02:00
|
|
|
if is_centered:
|
|
|
|
rect.center = (pos_x, pos_y)
|
|
|
|
else:
|
|
|
|
rect.topleft = (pos_x, pos_y)
|
2021-04-11 19:48:44 +02:00
|
|
|
|
2021-03-30 11:24:50 +02:00
|
|
|
if size is not None:
|
|
|
|
rect.size = (FIELD_SIZE, FIELD_SIZE)
|
2021-04-11 19:48:44 +02:00
|
|
|
|
2021-03-30 11:24:50 +02:00
|
|
|
screen.blit(scale, rect)
|