generowanie planszy #12
38
ekran.py
38
ekran.py
@ -1,5 +1,6 @@
|
||||
import pygame
|
||||
|
||||
from plansza import x1, y1, x2, y2, x3, y3, x4, y4, a_pix, b_pix
|
||||
import packageList
|
||||
import regal
|
||||
import wozek
|
||||
@ -18,25 +19,25 @@ pygame.display.set_icon(icon)
|
||||
lista_paczek = packageList.zainicjuj_liste_paczek()
|
||||
|
||||
def narysuj_regaly():
|
||||
regal.Regal(1, 1, 2, 2)
|
||||
regal.Regal(2, 1, 2, 3)
|
||||
regal.Regal(3, 1, 3, 2)
|
||||
regal.Regal(4, 1, 3, 3)
|
||||
regal.Regal(1, 1, x1, y1)
|
||||
regal.Regal(2, 1, x1, y1+1)
|
||||
regal.Regal(3, 1, x1+1, y1)
|
||||
regal.Regal(4, 1, x1+1, y1+1)
|
||||
|
||||
regal.Regal(5, 1, 10, 2)
|
||||
regal.Regal(6, 1, 10, 3)
|
||||
regal.Regal(7, 1, 11, 2)
|
||||
regal.Regal(8, 1, 11, 3)
|
||||
regal.Regal(5, 1, x2, y2)
|
||||
regal.Regal(6, 1, x2, y2+1)
|
||||
regal.Regal(7, 1, x2+1, y2)
|
||||
regal.Regal(8, 1, x2+1, y2+1)
|
||||
|
||||
regal.Regal(9, 1, 2, 8)
|
||||
regal.Regal(10, 1, 2, 9)
|
||||
regal.Regal(11, 1, 3, 8)
|
||||
regal.Regal(12, 1, 3, 9)
|
||||
regal.Regal(9, 1, x3, y3)
|
||||
regal.Regal(10, 1, x3, y3+1)
|
||||
regal.Regal(11, 1, x3+1, y3)
|
||||
regal.Regal(12, 1, x3+1, y3+1)
|
||||
|
||||
regal.Regal(13, 1, 10, 8)
|
||||
regal.Regal(14, 1, 10, 9)
|
||||
regal.Regal(15, 1, 11, 8)
|
||||
regal.Regal(16, 1, 11, 9)
|
||||
regal.Regal(13, 1, x4, y4)
|
||||
regal.Regal(14, 1, x4, y4+1)
|
||||
regal.Regal(15, 1, x4+1, y4)
|
||||
regal.Regal(16, 1, x4+1, y4+1)
|
||||
|
||||
|
||||
def narysuj_siatke():
|
||||
@ -50,8 +51,7 @@ def narysuj_siatke():
|
||||
|
||||
def odswiez_ekran(wozek):
|
||||
screen.fill((51, 51, 51)) # removes object trail
|
||||
#screen.blit(miejsce, (430, 400))
|
||||
screen.blit(miejsce,(420, 350))
|
||||
screen.blit(miejsce,(a_pix, b_pix))
|
||||
narysuj_siatke()
|
||||
narysuj_paczki(wozek)
|
||||
narysuj_regaly()
|
||||
@ -78,4 +78,4 @@ def sprawdz_ktora_kolumna(y):
|
||||
def narysuj_paczki(wozek):
|
||||
if wozek.ln == 0:
|
||||
for paczka in lista_paczek.list:
|
||||
paczka.narysuj(430, 400, screen)
|
||||
paczka.narysuj(a_pix, b_pix, screen)
|
||||
|
7
grid.py
7
grid.py
@ -1,4 +1,5 @@
|
||||
from enum import Enum
|
||||
from plansza import x1,x2,x3,x4,y1,y2,y3,y4,a,b
|
||||
|
||||
from typing import Tuple, Dict
|
||||
|
||||
@ -18,8 +19,8 @@ class SearchGrid:
|
||||
for i in range (0,14):
|
||||
for j in range(0,14):
|
||||
self.grid[(i, j)] = GridCellType.FREE
|
||||
for r, c in [(2,2), (2,3), (3,2), (3,3), (10,2), (10,3), (11,2), (11,3),
|
||||
(2,8), (2,9), (3,8), (3,9), (10,8), (10,9), (11,8), (11,9),]:
|
||||
for r, c in [(x1, y1), (x1, y1+1), (x1+1, y1), (x1+1, y1+1), (x2, y2), (x2+1, y2), (x2, y2+1), (x2+1, y2+1),
|
||||
(x3, y3), (x3+1, y3), (x3, y3+1), (x3+1, y3+1), (x4, y4), (x4+1, y4), (x4, y4+1), (x4+1, y4+1),]:
|
||||
self.grid[(r,c)] = GridCellType.RACK
|
||||
for m, n in [(6,5), (6,6), (7,5), (7,6)]:
|
||||
for m, n in [(a,b), (a+1,b), (a,b+1), (a+1,b+1)]:
|
||||
self.grid[(m,n)] = GridCellType.PLACE
|
46
plansza.py
Normal file
46
plansza.py
Normal file
@ -0,0 +1,46 @@
|
||||
import random
|
||||
|
||||
def obliczPixeleNaPodstawieKratek(wymiar): #Przeliczanie współrzędnych podanych w kratkach na pixele
|
||||
i = 1
|
||||
pixele = 73
|
||||
while (i < wymiar):
|
||||
pixele = pixele + 70
|
||||
i = i + 1
|
||||
return pixele
|
||||
|
||||
EKRAN_SZEROKOSC = 980
|
||||
EKRAN_WYSOKOSC = 980
|
||||
blockSize = 70
|
||||
|
||||
x1, y1, x2, y2, x3, y3, x4, y4 = [None] * 8
|
||||
|
||||
while True:
|
||||
|
||||
#wspolrzedne regalow
|
||||
x1 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
|
||||
y1 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
|
||||
x2 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
|
||||
y2 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
|
||||
x3 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
|
||||
y3 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
|
||||
x4 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
|
||||
y4 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
|
||||
|
||||
#wspolrzedne miejsca paczek
|
||||
a = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
|
||||
b = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
|
||||
|
||||
coords = [(x1, y1), (x1+1, y1), (x1, y1+1), (x1+1, y1+1),
|
||||
(x2, y2), (x2+1, y2), (x2, y2+1), (x2+1, y2+1),
|
||||
(x3, y3), (x3+1, y3), (x3, y3+1), (x3+1, y3+1),
|
||||
(x4, y4), (x4+1, y4), (x4, y4+1), (x4+1, y4+1),
|
||||
(a, b), (a+1, b), (a, b+1), (a+1, b+1)]
|
||||
|
||||
#sprawdzenie czy jakies wspolrzedne sie pokrywaja
|
||||
if len(coords) == len(set(coords)):
|
||||
break
|
||||
|
||||
x1, x2, x3, x4, y1, y2, y3, y4, a, b = map(int, [x1, x2, x3, x4, y1, y2, y3, y4, a, b])
|
||||
|
||||
a_pix = obliczPixeleNaPodstawieKratek(a)
|
||||
b_pix = obliczPixeleNaPodstawieKratek(b)
|
Loading…
Reference in New Issue
Block a user