Upload files to "/"
This commit is contained in:
parent
296f12d7d9
commit
45a159a0fc
30
main.py
30
main.py
@ -3,6 +3,8 @@ import random
|
||||
import time
|
||||
import numpy
|
||||
import threading
|
||||
import collections
|
||||
from collections import deque
|
||||
|
||||
kuchnia_xy = 0
|
||||
pozycja_startowa = 0
|
||||
@ -12,7 +14,24 @@ blockSize = 60
|
||||
rows = 14
|
||||
columns = 24
|
||||
|
||||
|
||||
# -----------------------------Inicjacja klas
|
||||
class Stan:
|
||||
def __init__(self,position, kierunek):
|
||||
self.position = position
|
||||
self.kierunek = kierunek
|
||||
|
||||
toVisit = deque()
|
||||
visited = deque()
|
||||
|
||||
def succ(self):
|
||||
newStan: Stan(x+1, y, 1)
|
||||
queue = deque([x, y, self.kierunek])
|
||||
print(queue[0])
|
||||
|
||||
#def BFS:
|
||||
|
||||
|
||||
class Kelner:
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
@ -29,6 +48,8 @@ class Kelner:
|
||||
kelnerRotated = pygame.transform.rotate(kelnerImg, -90 * kelner.kierunek)
|
||||
screen.blit(kelnerRotated, (self.x * blockSize, self.y * blockSize))
|
||||
|
||||
#def planuj_ruch(self):
|
||||
|
||||
def idz_do_stolika(self):
|
||||
self.cel_x, self.cel_y = self.stolik_docelowy.x, self.stolik_docelowy.y
|
||||
kelner.stan = "odbiera"
|
||||
@ -101,12 +122,15 @@ menuImg = pygame.transform.scale(menuImg, (blockSize / 2, blockSize / 2))
|
||||
kitchenImg = pygame.image.load("kitchen.png")
|
||||
kitchenImg = pygame.transform.scale(kitchenImg, (blockSize * 2, blockSize * 2))
|
||||
|
||||
|
||||
def kuchnia(x, y):
|
||||
screen.blit(kitchenImg, (x * blockSize, y * blockSize))
|
||||
|
||||
|
||||
def menu(x, y):
|
||||
screen.blit(menuImg, (x * blockSize, y * blockSize))
|
||||
|
||||
|
||||
def wypiszOkno():
|
||||
screen.fill((0, 0, 0))
|
||||
for x in range(0, width, blockSize):
|
||||
@ -114,6 +138,7 @@ def wypiszOkno():
|
||||
rect = pygame.Rect(x, y, blockSize, blockSize)
|
||||
pygame.draw.rect(screen, (200, 200, 200), rect, 1) # -------------Wypisz kratę -TA
|
||||
|
||||
|
||||
run = True
|
||||
|
||||
# czcionka = pygame.font.SysFont('Arial',50)
|
||||
@ -140,6 +165,7 @@ while run:
|
||||
menu(stolik.x, stolik.y)
|
||||
if kelner.stan == "stoi":
|
||||
kelner.stolik_docelowy = stolik
|
||||
#kelner.planuj_ruch()
|
||||
kelner.idz_do_stolika()
|
||||
|
||||
# ----------Losuje stoliki, które dokonają zamówienia
|
||||
@ -154,7 +180,6 @@ while run:
|
||||
# print(kelner.stan)--------------------------Wypisuje stan kelnera
|
||||
# print(f"{kelner.x} {kelner.y}")-------------Wypisuje wspolrzedne kelnera
|
||||
|
||||
|
||||
# --------------Zmiana kierunku kelnera
|
||||
if kelner.x != kelner.cel_x:
|
||||
if kelner.x < kelner.cel_x:
|
||||
@ -171,7 +196,6 @@ while run:
|
||||
if kelner.chodzi == True and licznik % (101 - kelner.speed) == 0: # ograniczenie prędkości
|
||||
kelner.idz_do_przodu()
|
||||
|
||||
|
||||
# ----------------Sprawdzenie, czy kelner jest u celu
|
||||
if kelner.x == kelner.cel_x and kelner.y == kelner.cel_y:
|
||||
if kelner.stan == "odbiera":
|
||||
@ -181,7 +205,6 @@ while run:
|
||||
elif kelner.stan == "wraca":
|
||||
kelner.stan = "stoi"
|
||||
|
||||
|
||||
time.sleep(0.001)
|
||||
|
||||
key = pygame.key.get_pressed()
|
||||
@ -189,4 +212,5 @@ while run:
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
run = False
|
||||
|
||||
pygame.quit()
|
Loading…
Reference in New Issue
Block a user