add tiles, movement on axi x and then y, kitchen, menu, kelnerStan
This commit is contained in:
parent
737d323257
commit
8ee7a2cc30
BIN
kitchen.png
Normal file
BIN
kitchen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
87
main.py
87
main.py
@ -1,12 +1,13 @@
|
|||||||
import pygame
|
import pygame
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
|
import threading
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
|
|
||||||
pygame.display.set_caption("Automatyczny kelner")
|
pygame.display.set_caption("Automatyczny kelner")
|
||||||
#----------------wymiary okna
|
#----------------wymiary okna
|
||||||
width = 1000
|
width = 1200
|
||||||
height = 800
|
height = 800
|
||||||
|
|
||||||
x_k = 1 #----------wspolrzedna x kelnera
|
x_k = 1 #----------wspolrzedna x kelnera
|
||||||
@ -15,12 +16,22 @@ y_k = 1 #----------wspolrzedna y kelnera
|
|||||||
screen = pygame.display.set_mode((width, height))
|
screen = pygame.display.set_mode((width, height))
|
||||||
|
|
||||||
#-----------wspolrzedna stolikow
|
#-----------wspolrzedna stolikow
|
||||||
coords = ["100 250", "800 250", "100 600", "800 600"]
|
coords = ["325 320", "325 640", "885 320", "885 640"]
|
||||||
|
zamowienia = [0, 0, 1, 1]
|
||||||
|
|
||||||
|
kelnerStan = 0 #--- 0 - brak zamowienia, 1 - zamownienie, 2 - danie
|
||||||
|
|
||||||
kelnerImg = pygame.image.load("kelner.png")
|
kelnerImg = pygame.image.load("kelner.png")
|
||||||
kelnerImg = pygame.transform.scale(kelnerImg, (100, 100))
|
kelnerImg = pygame.transform.scale(kelnerImg, (70, 70))
|
||||||
stolikImg = pygame.image.load("stolik.png")
|
stolikImg = pygame.image.load("stolik.png")
|
||||||
stolikImg = pygame.transform.scale(stolikImg, (140, 140))
|
stolikImg = pygame.transform.scale(stolikImg, (70, 70))
|
||||||
|
menuImg = pygame.image.load("menu.png")
|
||||||
|
menuImg = pygame.transform.scale(menuImg, (40, 40))
|
||||||
|
kitchenImg = pygame.image.load("kitchen.png")
|
||||||
|
kitchenImg = pygame.transform.scale(kitchenImg, (100, 100))
|
||||||
|
|
||||||
|
def kuchnia(x, y):
|
||||||
|
screen.blit(kitchenImg, (x, y))
|
||||||
|
|
||||||
def kelner(x, y):
|
def kelner(x, y):
|
||||||
screen.blit(kelnerImg, (x, y))
|
screen.blit(kelnerImg, (x, y))
|
||||||
@ -28,26 +39,75 @@ def kelner(x, y):
|
|||||||
def stolik(x, y):
|
def stolik(x, y):
|
||||||
screen.blit(stolikImg, (x, y))
|
screen.blit(stolikImg, (x, y))
|
||||||
|
|
||||||
|
def changeTable(x, y):
|
||||||
|
screen.blit(menuImg, (x, y))
|
||||||
|
|
||||||
|
|
||||||
|
#def randomoweZamowienia():
|
||||||
|
#threading.Timer(5.0).start()
|
||||||
|
#x = random.randrange(0, 4)
|
||||||
|
#if zamownienia[x] == 0:
|
||||||
|
#zamownienia[x] = 1
|
||||||
|
#stolikImg = pygame.image.load("menu.png") #----zmien
|
||||||
|
#stolikImg = pygame.transform.scale(stolikImg, (70, 70))
|
||||||
|
#screen.blit(stolikImg, (1, 1))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def wypiszOkno():
|
||||||
|
screen.fill((0, 0, 0))
|
||||||
|
blockSize = 80
|
||||||
|
for x in range(0, width, blockSize):
|
||||||
|
for y in range(0, height, blockSize):
|
||||||
|
rect = pygame.Rect(x, y, blockSize, blockSize)
|
||||||
|
pygame.draw.rect(screen, (200, 200, 200), rect, 1) #-------------Wypisz kratę -TA
|
||||||
|
|
||||||
#-------------Stolik do ktorego idzie kelner
|
#-------------Stolik do ktorego idzie kelner
|
||||||
cel = coords[random.randrange(0, 4)]
|
cel = coords[random.randrange(0, 4)]
|
||||||
run = True
|
run = True
|
||||||
|
|
||||||
|
#def randomTime():
|
||||||
|
# x = random.randrange(2, 20)
|
||||||
|
# threading.Timer(x, randomTime).start()
|
||||||
|
# y=random.randrange(0, 2)
|
||||||
|
# return y
|
||||||
|
|
||||||
|
#whichPic = randomTime()
|
||||||
|
|
||||||
while run:
|
while run:
|
||||||
|
|
||||||
screen.fill((0, 0, 0))
|
wypiszOkno()
|
||||||
|
kuchnia(40, 40)
|
||||||
kelner(x_k, y_k)
|
kelner(x_k, y_k)
|
||||||
|
if kelnerStan == 1:
|
||||||
|
changeTable(x_k, y_k)
|
||||||
|
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
test = coords[i]
|
test = coords[i]
|
||||||
x_y = test.split(" ")
|
x_y = test.split(" ")
|
||||||
x = int(x_y[0])
|
x = int(x_y[0])
|
||||||
y = int(x_y[1])
|
y = int(x_y[1])
|
||||||
stolik(x, y)
|
stolik(x ,y)
|
||||||
|
|
||||||
|
|
||||||
split = str(cel).split(" ")
|
split = str(cel).split(" ")
|
||||||
x_s = int(split[0])
|
x_s = int(split[0])
|
||||||
y_s = int(split[1])
|
y_s = int(split[1])
|
||||||
|
|
||||||
|
for j in range(len(zamowienia)): #------------weź zamowienie
|
||||||
|
if zamowienia[j] == 1:
|
||||||
|
test = coords[j]
|
||||||
|
x_y = test.split(" ")
|
||||||
|
x = int(x_y[0])
|
||||||
|
y = int(x_y[1])
|
||||||
|
changeTable(x, y)
|
||||||
|
split2 = str(coords[j]).split(" ")
|
||||||
|
x_s2 = int(split2[0])
|
||||||
|
y_s2 = int(split2[1])
|
||||||
|
if (x_k == x_s2) and (y_k == y_s2) and kelnerStan == 0:
|
||||||
|
zamowienia[j] = 0
|
||||||
|
kelnerStan = 1
|
||||||
|
|
||||||
#print("X_k: " + str(x_k) + " Y_k: " + str(y_k))-------------Wypisuje wspolrzedne kelnera
|
#print("X_k: " + str(x_k) + " Y_k: " + str(y_k))-------------Wypisuje wspolrzedne kelnera
|
||||||
|
|
||||||
#----------------Sprawdzenie w ktora strone ma isc kelner
|
#----------------Sprawdzenie w ktora strone ma isc kelner
|
||||||
@ -59,10 +119,19 @@ while run:
|
|||||||
y = (y_s - y_k) / abs(y_s - y_k)
|
y = (y_s - y_k) / abs(y_s - y_k)
|
||||||
else:
|
else:
|
||||||
y = 0
|
y = 0
|
||||||
x_k = x_k + x
|
|
||||||
y_k = y_k + y
|
if x != 0:
|
||||||
|
x_k = x_k + x
|
||||||
|
else:
|
||||||
|
y_k = y_k + y
|
||||||
if x_k == x_s and y_k == y_s:
|
if x_k == x_s and y_k == y_s:
|
||||||
cel = coords[random.randrange(0, 4)]
|
if kelnerStan == 1:
|
||||||
|
cel = "20 20"
|
||||||
|
else:
|
||||||
|
cel = coords[random.randrange(0, 4)]
|
||||||
|
|
||||||
|
if x_k == 20 and y_k == 20:
|
||||||
|
kelnerStan = 0
|
||||||
time.sleep(0.001)
|
time.sleep(0.001)
|
||||||
|
|
||||||
key = pygame.key.get_pressed()
|
key = pygame.key.get_pressed()
|
||||||
|
Loading…
Reference in New Issue
Block a user