59 lines
2.6 KiB
Python
59 lines
2.6 KiB
Python
|
import pygame
|
||
|
|
||
|
class Enclosure:
|
||
|
def __init__(self, x1, y1, x2, y2, type, imageH, imageV):
|
||
|
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
|
||
|
self.type = type #hot/cold/medium
|
||
|
self.imageH = imageH
|
||
|
self.imageV = imageV
|
||
|
|
||
|
def draw(self, screen, grid_size, blocked_fields):
|
||
|
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))
|
||
|
blocked_fields.add((i, self.y1))
|
||
|
screen.blit(self.imageH, (i * grid_size, self.y2 * grid_size))
|
||
|
blocked_fields.add((i, self.y2))
|
||
|
if self.y1 < self.y2:
|
||
|
for j in range(self.y1, self.y2+1):
|
||
|
screen.blit(self.imageH, (self.x1 * grid_size, j * grid_size))
|
||
|
blocked_fields.add((self.x1, j))
|
||
|
screen.blit(self.imageH, (self.x2 * grid_size, j * grid_size))
|
||
|
blocked_fields.add((self.x2, j))
|
||
|
if self.y1 > self.y2:
|
||
|
for j in range(self.y2, self.y1+1):
|
||
|
screen.blit(self.imageH, (self.x1 * grid_size, j * grid_size))
|
||
|
blocked_fields.add((self.x1, j))
|
||
|
screen.blit(self.imageH, (self.x2 * grid_size, j * grid_size))
|
||
|
blocked_fields.add((self.x2, j))
|
||
|
if self.x1 > self.x2:
|
||
|
for i in range(self.x2, self.x1+1):
|
||
|
screen.blit(self.imageH, (i * grid_size, self.y1 * grid_size))
|
||
|
blocked_fields.add((i, self.y1))
|
||
|
screen.blit(self.imageH, (i * grid_size, self.y2 * grid_size))
|
||
|
blocked_fields.add((i, self.y2))
|
||
|
if self.y1 < self.y2:
|
||
|
for j in range(self.y1, self.y2+1):
|
||
|
screen.blit(self.imageH, (self.x1 * grid_size, j * grid_size))
|
||
|
blocked_fields.add((self.x1, j))
|
||
|
screen.blit(self.imageH, (self.x2 * grid_size, j * grid_size))
|
||
|
blocked_fields.add((self.x2, j))
|
||
|
if self.y1 > self.y2:
|
||
|
for j in range(self.y2, self.y1+1):
|
||
|
screen.blit(self.imageH, (self.x1 * grid_size, j * grid_size))
|
||
|
blocked_fields.add((self.x1, j))
|
||
|
screen.blit(self.imageH, (self.x2 * grid_size, j * grid_size))
|
||
|
blocked_fields.add((self.x2, j))
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|