From 2afda6c7ffe52fae120ccacd6b0955d378ac473d Mon Sep 17 00:00:00 2001 From: Dominik Jagosz Date: Tue, 22 Mar 2022 14:32:26 +0100 Subject: [PATCH] Dodanie rysowania kraty liniami z main2.py --- etykieta.py | 10 +++++----- krata.py | 16 +++++++++++++++- stale.py | 52 +++++++++++++++++++++++++++++++--------------------- 3 files changed, 51 insertions(+), 27 deletions(-) diff --git a/etykieta.py b/etykieta.py index 42c174b..4da4a30 100644 --- a/etykieta.py +++ b/etykieta.py @@ -1,5 +1,5 @@ -nazwa_paczki ="" -producent ="" -numer_paczki=int -cecha_paczki ="" -data_wysylki= "" +nazwa_paczki = "" +producent = "" +numer_paczki = int +cecha_paczki = "" +data_wysylki = "" diff --git a/krata.py b/krata.py index ba69cfd..2d6d105 100644 --- a/krata.py +++ b/krata.py @@ -55,7 +55,8 @@ class Krata: self.krata[rzad].append(ZawartoscPola.PUSTE) def wyswietlKrate(self): - self.narysujKrate() + # self.narysujKrate() + self.narysujKrateAlternatywnie() self.narysujAgenta() pygame.display.update() @@ -67,6 +68,19 @@ class Krata: gora = (self.odstepMiedzyPolami + self.bokPola) * rzad + self.odstepMiedzyPolami pygame.draw.rect(self.okno, BIALY, [start, gora, self.bokPola, self.bokPola]) + def narysujKrateAlternatywnie(self): + self.okno.fill(SZARY1) + # for i in range(stale.NUMBER_OF_BLOCKS_WIDE): + # new_height = round(i * BLOCK_HEIGHT) + # new_width = round(i * BLOCK_HEIGHT) + # pygame.draw.line(surface, BLACK, (0, new_height), (SZEROKOSC_OKNA, new_height), 2) + # pygame.draw.line(surface, BLACK, (new_width, 0), (new_width, WYSOKOSC_OKNA), 2) + for i in range(LICZBA_POL_W_POZIOMIE + 1): + new_height = i * (BOK_POLA + ODSTEP_MIEDZY_POLAMI) + new_width = i * (BOK_POLA + ODSTEP_MIEDZY_POLAMI) + pygame.draw.line(self.okno, CZARNY, (0, new_height), (SZEROKOSC_OKNA, new_height), ODSTEP_MIEDZY_POLAMI) + pygame.draw.line(self.okno, CZARNY, (new_width, 0), (new_width, WYSOKOSC_OKNA), ODSTEP_MIEDZY_POLAMI) + def narysujAgenta(self): if self.agent is not None: self.okno.blit(self.agent.tekstura, (self.agent.hitbox.x, self.agent.hitbox.y)) diff --git a/stale.py b/stale.py index 9b573f8..41369c6 100644 --- a/stale.py +++ b/stale.py @@ -1,38 +1,48 @@ -FPS = 10 +FPS = 5 # # SZEROKOSC_OKNA = 1500 # WYSOKOSC_OKNA = 750 - +# LICZBA_POL_W_POZIOMIE = 60 LICZBA_POL_W_PIONIE = 30 BOK_POLA = 20 ODSTEP_MIEDZY_POLAMI = 2 SZEROKOSC_OKNA = LICZBA_POL_W_POZIOMIE * (BOK_POLA + ODSTEP_MIEDZY_POLAMI) + ODSTEP_MIEDZY_POLAMI WYSOKOSC_OKNA = LICZBA_POL_W_PIONIE * (BOK_POLA + ODSTEP_MIEDZY_POLAMI) + ODSTEP_MIEDZY_POLAMI - +# BOK_AGENTA1_W_POLACH = 3 BOK_AGENTA1 = BOK_AGENTA1_W_POLACH * (BOK_POLA + ODSTEP_MIEDZY_POLAMI) - ODSTEP_MIEDZY_POLAMI KROK_AGENTA1 = 2 - +# BIALY = (255, 255, 255) JASNOSZARY1 = (200, 200, 200) SZARY1 = (150, 150, 150) ZIELONY1 = (26, 122, 26) +CZARNY = (0, 0, 0) +### -GREY =(150,150,150) -RED =(255,0,0) -BLUE=(55,55,255) -BLACK =(0,0,0) -GREEN =(0,200,0) -DARKGREY=(150,150,150) -UGLY_PINK=(255,0,255) -BROWN=(153,76,0) -GOLD=(153,153,0) -DARKGREEN=(0,102,0) -DARKORANGE=(255,128,0) -NUMBER_OF_BLOCKS_WIDE=8 -NUMBER_OF_BLOCKS_HIGH=8 -BLOCK_HEIGHT=round(SZEROKOSC_OKNA/NUMBER_OF_BLOCKS_HIGH) -BLOCK_WIDTH=round(WYSOKOSC_OKNA/NUMBER_OF_BLOCKS_WIDE) -MAPFILE="map.txt" -TITLE ="Gierka" \ No newline at end of file +### +GREY = (150, 150, 150) +RED = (255, 0, 0) +BLUE = (55, 55, 255) +BLACK = (0, 0, 0) +GREEN = (0, 200, 0) +DARKGREY = (150, 150, 150) +UGLY_PINK = (255, 0, 255) +BROWN = (153, 76, 0) +GOLD = (153, 153, 0) +DARKGREEN = (0, 102, 0) +DARKORANGE = (255, 128, 0) +# +# NUMBER_OF_BLOCKS_WIDE=8 +# NUMBER_OF_BLOCKS_HIGH=8 +# BLOCK_HEIGHT=round(SZEROKOSC_OKNA/NUMBER_OF_BLOCKS_HIGH) +# BLOCK_WIDTH=round(WYSOKOSC_OKNA/NUMBER_OF_BLOCKS_WIDE) +# +MAPFILE = "map.txt" +TITLE = "Gierka" +# +NUMBER_OF_BLOCKS_WIDE = LICZBA_POL_W_POZIOMIE +NUMBER_OF_BLOCKS_HIGH = LICZBA_POL_W_PIONIE +BLOCK_HEIGHT = BOK_POLA +BLOCK_WIDTH = BOK_POLA