Dodane funkcje do pogody i pogoda na UI
This commit is contained in:
parent
8ab45974dc
commit
ff8f6eb0e8
14
field.py
14
field.py
@ -44,11 +44,17 @@ class field():
|
|||||||
|
|
||||||
def pogoda(self):
|
def pogoda(self):
|
||||||
number = random.randrange(0, 4)
|
number = random.randrange(0, 4)
|
||||||
if number==0:
|
return number
|
||||||
|
|
||||||
|
def get_pogoda_value(self):
|
||||||
|
return self.weather
|
||||||
|
|
||||||
|
def get_pogoda_name(self):
|
||||||
|
if self.weather==0:
|
||||||
return 'slonecznie'
|
return 'slonecznie'
|
||||||
elif number==1:
|
elif self.weather==1:
|
||||||
return 'deszcz'
|
return 'deszcz'
|
||||||
elif number==2:
|
elif self.weather==2:
|
||||||
return 'grad'
|
return 'grad'
|
||||||
elif number==3:
|
elif self.weather==3:
|
||||||
return 'zachmurzenie'
|
return 'zachmurzenie'
|
2
main.py
2
main.py
@ -60,7 +60,7 @@ while True:
|
|||||||
print(traktor.get_poz())
|
print(traktor.get_poz())
|
||||||
if key[K_F11]:
|
if key[K_F11]:
|
||||||
print(traktor.get_field_value())
|
print(traktor.get_field_value())
|
||||||
if key[K_12]:
|
if key[K_F12]:
|
||||||
c.main()
|
c.main()
|
||||||
|
|
||||||
UI.update()
|
UI.update()
|
||||||
|
5
ui.py
5
ui.py
@ -14,6 +14,8 @@ class game_ui():
|
|||||||
self.POLE_COL = (128, 128, 0)
|
self.POLE_COL = (128, 128, 0)
|
||||||
self.POLE_POZ = (75, 75)
|
self.POLE_POZ = (75, 75)
|
||||||
self.text_rect = [self.POLE_POZ[0], self.POLE_WYS + self.POLE_POZ[1] + 100]
|
self.text_rect = [self.POLE_POZ[0], self.POLE_WYS + self.POLE_POZ[1] + 100]
|
||||||
|
self.pogoda_rect = [self.POLE_POZ[0], self.POLE_WYS + self.POLE_POZ[1] + 125]
|
||||||
|
self.text_weather = "Pogoda: "+self.field.get_pogoda_name()
|
||||||
|
|
||||||
# Init pola gry
|
# Init pola gry
|
||||||
self.okno = pygame.display.set_mode((self.szer, self.wys), 0, 32)
|
self.okno = pygame.display.set_mode((self.szer, self.wys), 0, 32)
|
||||||
@ -50,9 +52,12 @@ class game_ui():
|
|||||||
self.okno.blit(self.pole1_surf, self.pole1_surf_rect)
|
self.okno.blit(self.pole1_surf, self.pole1_surf_rect)
|
||||||
self.okno.blit(self.pole_surf, self.pole_surf_rect)
|
self.okno.blit(self.pole_surf, self.pole_surf_rect)
|
||||||
self.text_value = "Ile ruchów: " + str(self.traktor.get_moves()) + " Tryb: " + self.traktor.get_mode_name()
|
self.text_value = "Ile ruchów: " + str(self.traktor.get_moves()) + " Tryb: " + self.traktor.get_mode_name()
|
||||||
|
|
||||||
self.font = pygame.font.Font('freesansbold.ttf', 24)
|
self.font = pygame.font.Font('freesansbold.ttf', 24)
|
||||||
self.text = self.font.render(self.text_value, True, (0, 0, 0), self.col)
|
self.text = self.font.render(self.text_value, True, (0, 0, 0), self.col)
|
||||||
|
self.text_pogoda = self.font.render(self.text_weather, True,(0, 0, 0), self.col)
|
||||||
self.okno.blit(self.text, self.text_rect)
|
self.okno.blit(self.text, self.text_rect)
|
||||||
|
self.okno.blit(self.text_pogoda, self.pogoda_rect)
|
||||||
for i in range(0, 10):
|
for i in range(0, 10):
|
||||||
for j in range(0, 10):
|
for j in range(0, 10):
|
||||||
self.pole_surf.blit(self.field_images[self.field.get_value([i,j])], (i*70, j*70))
|
self.pole_surf.blit(self.field_images[self.field.get_value([i,j])], (i*70, j*70))
|
||||||
|
Loading…
Reference in New Issue
Block a user