Dodanie rysowania kraty liniami z main2.py
This commit is contained in:
parent
e8b5d96263
commit
2afda6c7ff
16
krata.py
16
krata.py
@ -55,7 +55,8 @@ class Krata:
|
|||||||
self.krata[rzad].append(ZawartoscPola.PUSTE)
|
self.krata[rzad].append(ZawartoscPola.PUSTE)
|
||||||
|
|
||||||
def wyswietlKrate(self):
|
def wyswietlKrate(self):
|
||||||
self.narysujKrate()
|
# self.narysujKrate()
|
||||||
|
self.narysujKrateAlternatywnie()
|
||||||
self.narysujAgenta()
|
self.narysujAgenta()
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
|
|
||||||
@ -67,6 +68,19 @@ class Krata:
|
|||||||
gora = (self.odstepMiedzyPolami + self.bokPola) * rzad + self.odstepMiedzyPolami
|
gora = (self.odstepMiedzyPolami + self.bokPola) * rzad + self.odstepMiedzyPolami
|
||||||
pygame.draw.rect(self.okno, BIALY, [start, gora, self.bokPola, self.bokPola])
|
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):
|
def narysujAgenta(self):
|
||||||
if self.agent is not None:
|
if self.agent is not None:
|
||||||
self.okno.blit(self.agent.tekstura, (self.agent.hitbox.x, self.agent.hitbox.y))
|
self.okno.blit(self.agent.tekstura, (self.agent.hitbox.x, self.agent.hitbox.y))
|
||||||
|
26
stale.py
26
stale.py
@ -1,24 +1,27 @@
|
|||||||
FPS = 10
|
FPS = 5
|
||||||
#
|
#
|
||||||
# SZEROKOSC_OKNA = 1500
|
# SZEROKOSC_OKNA = 1500
|
||||||
# WYSOKOSC_OKNA = 750
|
# WYSOKOSC_OKNA = 750
|
||||||
|
#
|
||||||
LICZBA_POL_W_POZIOMIE = 60
|
LICZBA_POL_W_POZIOMIE = 60
|
||||||
LICZBA_POL_W_PIONIE = 30
|
LICZBA_POL_W_PIONIE = 30
|
||||||
BOK_POLA = 20
|
BOK_POLA = 20
|
||||||
ODSTEP_MIEDZY_POLAMI = 2
|
ODSTEP_MIEDZY_POLAMI = 2
|
||||||
SZEROKOSC_OKNA = LICZBA_POL_W_POZIOMIE * (BOK_POLA + ODSTEP_MIEDZY_POLAMI) + ODSTEP_MIEDZY_POLAMI
|
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
|
WYSOKOSC_OKNA = LICZBA_POL_W_PIONIE * (BOK_POLA + ODSTEP_MIEDZY_POLAMI) + ODSTEP_MIEDZY_POLAMI
|
||||||
|
#
|
||||||
BOK_AGENTA1_W_POLACH = 3
|
BOK_AGENTA1_W_POLACH = 3
|
||||||
BOK_AGENTA1 = BOK_AGENTA1_W_POLACH * (BOK_POLA + ODSTEP_MIEDZY_POLAMI) - ODSTEP_MIEDZY_POLAMI
|
BOK_AGENTA1 = BOK_AGENTA1_W_POLACH * (BOK_POLA + ODSTEP_MIEDZY_POLAMI) - ODSTEP_MIEDZY_POLAMI
|
||||||
KROK_AGENTA1 = 2
|
KROK_AGENTA1 = 2
|
||||||
|
#
|
||||||
BIALY = (255, 255, 255)
|
BIALY = (255, 255, 255)
|
||||||
JASNOSZARY1 = (200, 200, 200)
|
JASNOSZARY1 = (200, 200, 200)
|
||||||
SZARY1 = (150, 150, 150)
|
SZARY1 = (150, 150, 150)
|
||||||
ZIELONY1 = (26, 122, 26)
|
ZIELONY1 = (26, 122, 26)
|
||||||
|
CZARNY = (0, 0, 0)
|
||||||
|
###
|
||||||
|
|
||||||
|
###
|
||||||
GREY = (150, 150, 150)
|
GREY = (150, 150, 150)
|
||||||
RED = (255, 0, 0)
|
RED = (255, 0, 0)
|
||||||
BLUE = (55, 55, 255)
|
BLUE = (55, 55, 255)
|
||||||
@ -30,9 +33,16 @@ BROWN=(153,76,0)
|
|||||||
GOLD = (153, 153, 0)
|
GOLD = (153, 153, 0)
|
||||||
DARKGREEN = (0, 102, 0)
|
DARKGREEN = (0, 102, 0)
|
||||||
DARKORANGE = (255, 128, 0)
|
DARKORANGE = (255, 128, 0)
|
||||||
NUMBER_OF_BLOCKS_WIDE=8
|
#
|
||||||
NUMBER_OF_BLOCKS_HIGH=8
|
# NUMBER_OF_BLOCKS_WIDE=8
|
||||||
BLOCK_HEIGHT=round(SZEROKOSC_OKNA/NUMBER_OF_BLOCKS_HIGH)
|
# NUMBER_OF_BLOCKS_HIGH=8
|
||||||
BLOCK_WIDTH=round(WYSOKOSC_OKNA/NUMBER_OF_BLOCKS_WIDE)
|
# BLOCK_HEIGHT=round(SZEROKOSC_OKNA/NUMBER_OF_BLOCKS_HIGH)
|
||||||
|
# BLOCK_WIDTH=round(WYSOKOSC_OKNA/NUMBER_OF_BLOCKS_WIDE)
|
||||||
|
#
|
||||||
MAPFILE = "map.txt"
|
MAPFILE = "map.txt"
|
||||||
TITLE = "Gierka"
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user