diff --git a/Environment.py b/Environment.py new file mode 100644 index 0000000..ac879cc --- /dev/null +++ b/Environment.py @@ -0,0 +1,21 @@ +import pygame +from Shelf import Shelf +from Grid import Grid + +HORIZONTAL = 1250 +VERTICAL = 750 + +TILE_SIZE = 50 + +background = (49, 51, 53) + +class Environment: + def __init__(self, window): + self.window = window + self.grid = Grid(self.window) + self.Shelf = Shelf(self.window) + + def drawEnviroment(self): + self.window.fill(background) + self.Shelf.drawShelves() + self.grid.drawGrid() \ No newline at end of file diff --git a/Forklift.py b/Forklift.py new file mode 100644 index 0000000..62e10ce --- /dev/null +++ b/Forklift.py @@ -0,0 +1,37 @@ +import pygame +from Environment import Environment +from Package import Package + +TILE_SIZE = 50 + +class Forklift: + def __init__(self, window): + self.window = window + self.image = pygame.image.load('resources/images.png').convert_alpha() + self.x = 50 + self.y = 350 + self.environment = Environment(self.window) + self.hasPackage = False + self.package = Package(self.window) + + def drawForklift(self): + self.environment.drawEnviroment() + self.package.drawPackage() + self.window.blit(self.image, (self.x, self.y)) + pygame.display.flip() + + def moveForkliftRight(self): + self.x += TILE_SIZE + self.drawForklift() + + def moveForkliftLeft(self): + self.x -= TILE_SIZE + self.drawForklift() + + def moveForkliftUp(self): + self.y -= TILE_SIZE + self.drawForklift() + + def moveForkliftDown(self): + self.y += TILE_SIZE + self.drawForklift() diff --git a/Grid.py b/Grid.py new file mode 100644 index 0000000..5e9f2b9 --- /dev/null +++ b/Grid.py @@ -0,0 +1,24 @@ +import pygame + +HORIZONTAL = 1250 +VERTICAL = 750 + +TILE_SIZE = 50 + +line_color = (85, 85, 85) + +class Grid: + def __init__(self, window): + self.window = window + + def drawGrid(self): + num_of_columns = int(HORIZONTAL / TILE_SIZE) + num_of_rows = int(VERTICAL / TILE_SIZE) + x = 0 + y = 0 + for i in range(num_of_columns): + x += TILE_SIZE + pygame.draw.line(self.window, line_color, (x, 0), (x, VERTICAL)) + for i in range(num_of_rows): + y += TILE_SIZE + pygame.draw.line(self.window, line_color, (0, y), (HORIZONTAL, y)) \ No newline at end of file diff --git a/Package.py b/Package.py new file mode 100644 index 0000000..89976a7 --- /dev/null +++ b/Package.py @@ -0,0 +1,25 @@ +import numpy as np +import pygame +import glob2 +import random + +TILE_SIZE = 50 + +class Package: + def __init__(self, window): + self.window = window + self.imageDefault = pygame.image.load('resources/indeks.png').convert_alpha() + self.x = 1150 + self.y = 350 + self.markImage = self.getMarkingImage() + + def getMarkingImage(self): + file_path_type = ["resources/package/*.jpg"] + images = glob2.glob(random.choice(file_path_type)) + markImage = random.choice(images) + print(markImage) + return markImage + + def drawPackage(self): + self.window.blit(self.imageDefault, (self.x, self.y)) + pygame.display.flip() \ No newline at end of file diff --git a/Program.py b/Program.py new file mode 100644 index 0000000..22be7aa --- /dev/null +++ b/Program.py @@ -0,0 +1,36 @@ +import pygame +from pygame.locals import * +from Forklift import Forklift + +HORIZONTAL = 1250 +VERTICAL = 750 + +TILE_SIZE = 50 + +class Program: + def __init__(self): + pygame.init() + self.window = pygame.display.set_mode((HORIZONTAL, VERTICAL)) + self.caption = pygame.display.set_caption('Autonomiczny wózek widłowy') + self.agent = Forklift(self.window) + self.agent.drawForklift() + + def run(self): + running = True + while running: + for event in pygame.event.get(): + if event.type == KEYDOWN: + if event.key == K_RIGHT: + self.agent.moveForkliftRight() + if event.key == K_LEFT: + self.agent.moveForkliftLeft() + if event.key == K_UP: + self.agent.moveForkliftUp() + if event.key == K_DOWN: + self.agent.moveForkliftDown() + if event.key == K_ESCAPE: + running = False + elif event.type == pygame.QUIT: + running = False + + diff --git a/Shelf.py b/Shelf.py new file mode 100644 index 0000000..43a5567 --- /dev/null +++ b/Shelf.py @@ -0,0 +1,24 @@ +import pygame + +HORIZONTAL = 1250 +VERTICAL = 750 + +TILE_SIZE = 50 +shelf = (138, 126, 74) + +class Shelf: + def __init__(self, window): + self.window = window + self.color = shelf + self.width = 5 * TILE_SIZE + self.height = TILE_SIZE + + def drawShelves(self): + + for j in range(0, 5 * TILE_SIZE, 2 * TILE_SIZE): + for i in range(TILE_SIZE + 1, HORIZONTAL - TILE_SIZE, 6 * TILE_SIZE): + pygame.draw.rect(self.window, shelf, pygame.Rect(i, j, self.width, self.height)) + + for k in range(VERTICAL - 5 * TILE_SIZE, VERTICAL, 2 * TILE_SIZE): + for l in range(TILE_SIZE + 1, HORIZONTAL - TILE_SIZE, 6 * TILE_SIZE): + pygame.draw.rect(self.window, shelf, pygame.Rect(l, k, self.width, self.height)) \ No newline at end of file diff --git a/__pycache__/Environment.cpython-39.pyc b/__pycache__/Environment.cpython-39.pyc new file mode 100644 index 0000000..838d3e4 Binary files /dev/null and b/__pycache__/Environment.cpython-39.pyc differ diff --git a/__pycache__/Forklift.cpython-39.pyc b/__pycache__/Forklift.cpython-39.pyc new file mode 100644 index 0000000..cb0fe24 Binary files /dev/null and b/__pycache__/Forklift.cpython-39.pyc differ diff --git a/__pycache__/Grid.cpython-39.pyc b/__pycache__/Grid.cpython-39.pyc new file mode 100644 index 0000000..54ac23c Binary files /dev/null and b/__pycache__/Grid.cpython-39.pyc differ diff --git a/__pycache__/Package.cpython-39.pyc b/__pycache__/Package.cpython-39.pyc new file mode 100644 index 0000000..8bb6b2d Binary files /dev/null and b/__pycache__/Package.cpython-39.pyc differ diff --git a/__pycache__/Program.cpython-39.pyc b/__pycache__/Program.cpython-39.pyc new file mode 100644 index 0000000..6a677b0 Binary files /dev/null and b/__pycache__/Program.cpython-39.pyc differ diff --git a/__pycache__/Shelf.cpython-39.pyc b/__pycache__/Shelf.cpython-39.pyc new file mode 100644 index 0000000..a5475e7 Binary files /dev/null and b/__pycache__/Shelf.cpython-39.pyc differ diff --git a/main.py b/main.py index 3596472..ab6f9c2 100644 --- a/main.py +++ b/main.py @@ -1,87 +1,7 @@ import pygame from pygame.locals import * - -HORIZONTAL = 1250 # poziomy wymiar okna -VERTICAL = 750 # pionowy wymiar okna - -TILE_SIZE = 50 # rozmiar kafelka - -background = (49, 51, 53) # kolor tla -line_color = (85, 85, 85) # kolor linii -shelf = (138, 126, 74) # kolor polki - -window = pygame.display.set_mode((HORIZONTAL, VERTICAL)) # okno 1250 x 750 -pygame.display.set_caption('Autonomiczny wózek widłowy') - -def drawGrid(): - num_of_columns = int(HORIZONTAL / TILE_SIZE) - num_of_rows = int(VERTICAL / TILE_SIZE) - x = 0 - y = 0 - for i in range(num_of_columns): - x += TILE_SIZE - pygame.draw.line(window, line_color, (x, 0), (x, VERTICAL)) - for i in range(num_of_rows): - y += TILE_SIZE - pygame.draw.line(window, line_color, (0, y), (HORIZONTAL, y)) - -def drawShelves(): - width = 5 * TILE_SIZE - height = TILE_SIZE - for i in range(TILE_SIZE + 1, HORIZONTAL - TILE_SIZE, 6 * TILE_SIZE): - pygame.draw.rect(window, shelf, pygame.Rect(i, 0, width, height)) - pygame.draw.rect(window, shelf, pygame.Rect(i, 101, width, height)) - pygame.draw.rect(window, shelf, pygame.Rect(i, 201, width, height)) - pygame.draw.rect(window, shelf, pygame.Rect(i, 501, width, height)) - pygame.draw.rect(window, shelf, pygame.Rect(i, 601, width, height)) - pygame.draw.rect(window, shelf, pygame.Rect(i, 701, width, height)) - -class Forklift: - def __init__(self): - self.image = pygame.image.load('resources/images.png').convert_alpha() - self.x = 50 - self.y = 350 - - def drawForklift(self): - window.blit(self.image, (self.x, self.y)) - -class Package: - def __init__(self): - self.image = pygame.image.load('resources/indeks.png').convert_alpha() - self.x = 1150 - self.y = 350 - - def drawPackage(self): - window.blit(self.image, (self.x, self.y)) - -def run(): - running = True - - forklift = Forklift() - package = Package() - - while running: - for event in pygame.event.get(): - if event.type == KEYDOWN: - if event.key == K_RIGHT: - forklift.x += TILE_SIZE - if event.key == K_LEFT: - forklift.x -= TILE_SIZE - if event.key == K_UP: - forklift.y -= TILE_SIZE - if event.key == K_DOWN: - forklift.y += TILE_SIZE - if event.key == K_ESCAPE: - running = False - elif event.type == pygame.QUIT: - running = False - - window.fill(background) - drawGrid() - drawShelves() - forklift.drawForklift() - package.drawPackage() - pygame.display.flip() +from Program import Program if __name__ == "__main__": - run() + program = Program() + program.run() diff --git a/resources/package/1.jpg b/resources/package/1.jpg new file mode 100644 index 0000000..4f35d5e Binary files /dev/null and b/resources/package/1.jpg differ diff --git a/resources/package/2.jpg b/resources/package/2.jpg new file mode 100644 index 0000000..f28e246 Binary files /dev/null and b/resources/package/2.jpg differ diff --git a/resources/package/3.jpg b/resources/package/3.jpg new file mode 100644 index 0000000..f70c9c0 Binary files /dev/null and b/resources/package/3.jpg differ diff --git a/resources/package/4.jpg b/resources/package/4.jpg new file mode 100644 index 0000000..33883ee Binary files /dev/null and b/resources/package/4.jpg differ diff --git a/resources/package/5.jpg b/resources/package/5.jpg new file mode 100644 index 0000000..b5de4e8 Binary files /dev/null and b/resources/package/5.jpg differ diff --git a/resources/package/6.jpg b/resources/package/6.jpg new file mode 100644 index 0000000..c10ba62 Binary files /dev/null and b/resources/package/6.jpg differ diff --git a/resources/package/7.jpg b/resources/package/7.jpg new file mode 100644 index 0000000..57dd11b Binary files /dev/null and b/resources/package/7.jpg differ diff --git a/resources/packaging-symbols-set_389832-806_jpg.jpg b/resources/packaging-symbols-set_389832-806_jpg.jpg new file mode 100644 index 0000000..318d635 Binary files /dev/null and b/resources/packaging-symbols-set_389832-806_jpg.jpg differ