2024-03-24 14:55:49 +01:00
|
|
|
import pygame
|
|
|
|
|
|
|
|
class Enclosure:
|
2024-03-24 17:33:58 +01:00
|
|
|
def __init__(self, x1, y1, x2, y2, gate, type, imageH, imageV, imageGate):
|
2024-03-24 14:55:49 +01:00
|
|
|
self.x1 = x1 - 1
|
|
|
|
self.y1 = y1 - 1
|
|
|
|
#(x1,y1) - wierzchołek przekątnej
|
|
|
|
self.x2 = x2 - 1
|
|
|
|
self.y2 = y2 - 1
|
|
|
|
#(x2,y2) - 2 wierzchołek przekątnej
|
2024-03-24 17:33:58 +01:00
|
|
|
self.gate = gate
|
|
|
|
self.type = type
|
2024-03-24 14:55:49 +01:00
|
|
|
self.imageH = imageH
|
|
|
|
self.imageV = imageV
|
2024-03-24 17:33:58 +01:00
|
|
|
self.imageGate = imageGate
|
2024-03-24 14:55:49 +01:00
|
|
|
|
2024-03-24 17:33:58 +01:00
|
|
|
def gatebuild(self, screen, grid_size):
|
|
|
|
self.imageGate = pygame.transform.scale(self.imageGate, (grid_size, grid_size))
|
|
|
|
gate_x, gate_y = self.gate
|
|
|
|
gate_x-=1
|
|
|
|
gate_y-=1
|
|
|
|
rect = pygame.Rect(gate_x * grid_size, gate_y * grid_size, grid_size, grid_size)
|
|
|
|
pygame.draw.rect(screen, (0, 0, 0), rect) # Fill the area with
|
|
|
|
screen.blit(self.imageGate, (gate_x * grid_size, gate_y * grid_size))
|
|
|
|
|
2024-04-16 14:50:06 +02:00
|
|
|
def draw(self,screen, grid_size):
|
2024-03-24 14:55:49 +01:00
|
|
|
self.imageH = pygame.transform.scale(self.imageH, (grid_size, grid_size))
|
|
|
|
self.imageV = pygame.transform.scale(self.imageV, (grid_size, grid_size))
|
|
|
|
if self.x1 < self.x2:
|
|
|
|
for i in range(self.x1, self.x2+1):
|
|
|
|
screen.blit(self.imageH, (i * grid_size, self.y1 * grid_size))
|
|
|
|
screen.blit(self.imageH, (i * grid_size, self.y2 * grid_size))
|
2024-04-16 14:50:06 +02:00
|
|
|
for j in range(self.y1, self.y2+1):
|
|
|
|
screen.blit(self.imageV, (self.x1 * grid_size, j * grid_size))
|
|
|
|
screen.blit(self.imageV, (self.x2 * grid_size, j * grid_size))
|