2022-03-24 20:02:21 +01:00
|
|
|
import numpy as np
|
|
|
|
import glob2
|
|
|
|
import pygame
|
|
|
|
import random
|
2022-04-25 17:26:32 +02:00
|
|
|
from Field import Field
|
|
|
|
from Global_variables import Global_variables as G_var
|
|
|
|
from Package_types import Package_types
|
2022-03-24 20:02:21 +01:00
|
|
|
|
|
|
|
|
2022-04-25 17:26:32 +02:00
|
|
|
class Package(Field):
|
|
|
|
def __init__(self, window, x, y):
|
|
|
|
Field.__init__(self, window, x, y)
|
2022-03-24 20:02:21 +01:00
|
|
|
self.mark_image = self.get_marking_photo()
|
2022-04-25 17:26:32 +02:00
|
|
|
self.type = random.choice(list(Package_types))
|
2022-04-25 17:58:51 +02:00
|
|
|
self.is_placed = False
|
2022-03-24 20:02:21 +01:00
|
|
|
|
|
|
|
def get_marking_photo(self):
|
|
|
|
file_path_type = ["resources/package_markings/*.jpg"]
|
|
|
|
images = glob2.glob(random.choice(file_path_type))
|
|
|
|
random_image = random.choice(images)
|
|
|
|
print(random_image)
|
|
|
|
return random_image
|
|
|
|
|
|
|
|
def draw(self):
|
2022-04-25 17:26:32 +02:00
|
|
|
self.color = self.get_package_color(self.type)
|
|
|
|
block = pygame.Rect(self.x * G_var().RECT_SIZE, self.y *
|
|
|
|
G_var().RECT_SIZE, G_var().RECT_SIZE, G_var().RECT_SIZE)
|
|
|
|
pygame.draw.rect(self.window, self.color, block)
|
2022-03-24 20:02:21 +01:00
|
|
|
|
2022-04-25 17:26:32 +02:00
|
|
|
def get_package_color(self, package_type):
|
|
|
|
color = (100, 50, 20)
|
|
|
|
if package_type == Package_types.fragile:
|
|
|
|
color = (255, 57, 32)
|
|
|
|
elif package_type == Package_types.priority:
|
|
|
|
color = (10, 34, 255)
|
|
|
|
return color
|