2022-03-07 20:41:12 +01:00
|
|
|
import os
|
|
|
|
|
2022-03-21 19:41:34 +01:00
|
|
|
from klasy import *
|
|
|
|
|
2022-03-09 12:27:02 +01:00
|
|
|
from agenci import *
|
2022-03-07 20:41:12 +01:00
|
|
|
|
|
|
|
OKNO = pygame.display.set_mode((SZEROKOSC_OKNA, WYSOKOSC_OKNA))
|
|
|
|
pygame.display.set_caption("Okno1")
|
2022-03-21 19:41:34 +01:00
|
|
|
Krata = Krata(OKNO)
|
2022-03-10 19:41:05 +01:00
|
|
|
|
2022-03-08 23:00:29 +01:00
|
|
|
|
2022-03-10 19:41:05 +01:00
|
|
|
def wyswietl_agentow():
|
2022-03-21 19:41:34 +01:00
|
|
|
for a in Agent1.Agenci:
|
2022-03-09 12:27:02 +01:00
|
|
|
OKNO.blit(a.tekstura, (a.hitbox.x, a.hitbox.y))
|
|
|
|
if a.droga == 0:
|
|
|
|
a.obierzNowyKierunek()
|
2022-03-09 16:08:26 +01:00
|
|
|
a.okreslDlugoscDrogi()
|
2022-03-10 19:41:05 +01:00
|
|
|
# a.ruszSie(Agenci1)
|
2022-03-08 18:38:43 +01:00
|
|
|
pygame.display.update()
|
|
|
|
|
|
|
|
|
2022-03-10 19:41:05 +01:00
|
|
|
def czy_wylosowane_dla_agenta_pola_sa_puste(pole_lewe_gorne):
|
|
|
|
wynik = True
|
|
|
|
for wiersz in range(pole_lewe_gorne.wiersz, pole_lewe_gorne.wiersz + BOK_AGENTA1_W_POLACH):
|
|
|
|
for kolumna in range(pole_lewe_gorne.kolumna, pole_lewe_gorne.kolumna + BOK_AGENTA1_W_POLACH):
|
2022-03-21 19:41:34 +01:00
|
|
|
if Krata.krata[wiersz][kolumna] != POLE.PUSTE:
|
2022-03-10 19:41:05 +01:00
|
|
|
wynik = False
|
|
|
|
break
|
|
|
|
if wynik == False:
|
|
|
|
break
|
|
|
|
return wynik
|
|
|
|
|
|
|
|
|
2022-03-09 12:27:02 +01:00
|
|
|
def dodaj_agenta1():
|
2022-03-09 16:08:26 +01:00
|
|
|
los = None
|
2022-03-21 19:41:34 +01:00
|
|
|
if len(Agent1.Agenci) in range(0, 40):
|
2022-03-09 16:08:26 +01:00
|
|
|
los = random.randint(1, 150)
|
2022-03-21 19:41:34 +01:00
|
|
|
elif len(Agent1.Agenci) in range(40, 50):
|
2022-03-09 16:08:26 +01:00
|
|
|
los = random.randint(1, 15)
|
|
|
|
if los != None:
|
2022-03-09 12:27:02 +01:00
|
|
|
pom = None
|
2022-03-21 19:41:34 +01:00
|
|
|
if los in (1, 2) or len(Agent1.Agenci) == 0:
|
2022-03-09 12:27:02 +01:00
|
|
|
pom = 'wozek.png'
|
2022-03-09 16:08:26 +01:00
|
|
|
elif los in (3, 4):
|
2022-03-09 12:27:02 +01:00
|
|
|
pom = 'wozek_ze_skrzynka.png'
|
2022-03-21 19:41:34 +01:00
|
|
|
elif los == 5 and len(Agent1.Agenci) > 6:
|
2022-03-09 12:27:02 +01:00
|
|
|
pom = 'traktor_ikona.png'
|
|
|
|
if pom != None:
|
2022-03-10 19:41:05 +01:00
|
|
|
pole_lewe_gorne = Pole(random.randint(0, LICZBA_POL_W_PIONIE - BOK_AGENTA1_W_POLACH),
|
|
|
|
random.randint(0, LICZBA_POL_W_POZIOMIE - BOK_AGENTA1_W_POLACH))
|
2022-03-21 19:41:34 +01:00
|
|
|
if len(Agent1.Agenci) == 0:
|
2022-03-10 19:41:05 +01:00
|
|
|
pole_lewe_gorne = Pole(0, 0)
|
|
|
|
if czy_wylosowane_dla_agenta_pola_sa_puste(pole_lewe_gorne):
|
2022-03-21 19:41:34 +01:00
|
|
|
pom = 'test1_ikona.png'
|
2022-03-09 16:08:26 +01:00
|
|
|
ikona = pygame.transform.scale(pygame.image.load(os.path.join('Ikony', pom)),
|
|
|
|
(BOK_AGENTA1, BOK_AGENTA1))
|
2022-03-10 19:41:05 +01:00
|
|
|
nowy_agent = Agent1(pole_lewe_gorne, ikona, KIERUNEK.GORA, 0)
|
|
|
|
nowy_agent.zaznacz_zajmowane_pola_na_kracie(Krata)
|
2022-03-21 19:41:34 +01:00
|
|
|
Agent1.Agenci.append(nowy_agent)
|
2022-03-10 19:41:05 +01:00
|
|
|
# print(Krata)
|
2022-03-09 12:27:02 +01:00
|
|
|
|
|
|
|
|
2022-03-08 23:00:29 +01:00
|
|
|
def main():
|
|
|
|
klatkaz = pygame.time.Clock()
|
|
|
|
warunek_dzialania = True
|
|
|
|
while warunek_dzialania:
|
|
|
|
klatkaz.tick(FPS)
|
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
|
|
|
warunek_dzialania = False
|
|
|
|
break
|
2022-03-21 19:41:34 +01:00
|
|
|
Krata.wyswietl_krate()
|
2022-03-10 19:41:05 +01:00
|
|
|
wyswietl_agentow()
|
2022-03-09 12:27:02 +01:00
|
|
|
dodaj_agenta1()
|
2022-03-08 23:00:29 +01:00
|
|
|
pygame.quit()
|
2022-03-08 18:38:43 +01:00
|
|
|
|
2022-03-07 20:41:12 +01:00
|
|
|
|
2022-03-08 23:00:29 +01:00
|
|
|
main()
|