generowanie pozycji domow / usuniete profile sRGB z zdjec domow

This commit is contained in:
Adam Osiowy 2020-04-03 21:41:59 +02:00
parent 09df30d7da
commit 06009e5cbd
7 changed files with 36 additions and 17 deletions

19
game.py
View File

@ -1,6 +1,4 @@
# TODO: sledzenie pozycji smieciarki
# TODO: pole na ktorym wypisywane beda informacje
# TODO: obsluga kolizji
# TODO: okienko z informacjami
import pygame
@ -69,22 +67,19 @@ plansza[4, 4].setJestKontenerem(True)
doms_array = ['resources/plansza/domy/dom1.png', 'resources/plansza/domy/dom2.png',
'resources/plansza/domy/dom3.png', 'resources/plansza/domy/dom4.png', 'resources/plansza/domy/dom5.png']
temp = random.sample(range(5, 14))
k = 0
for i in range(0, 4):
dom = modele.Dom(temp[k], temp[k+1])
dom.setImage(pygame.image.load(random.choice(doms_array)))
plansza[temp[k], temp[k+1]].setJestDomem(True)
all_sprites_list.add(dom)
k = k+2
wspolrzedne_domow = modele.generujWspolrzedneDomow()
for i in range(len(wspolrzedne_domow)):
dom = modele.Dom(wspolrzedne_domow[i, 0], wspolrzedne_domow[i, 1])
dom.setImage(pygame.image.load(random.choice(doms_array)))
plansza[wspolrzedne_domow[i, 0], wspolrzedne_domow[i, 1]].setJestDomem(True)
all_sprites_list.add(dom)
# ustawienie wysypiska, rozmiar wysypiska 5x5
for i in range(5):
for j in range(5):
plansza[i, j].setJestWysypiskiem(True)
all_sprites_list.add(kontener_plastik, kontener_metal, kontener_organiczne, kontener_papier, kontener_szklo,
smieciarka)

View File

@ -1,6 +1,8 @@
import pygame
import game
import random
import numpy as np
import random
# This sets the WIDTH and HEIGHT of each grid location
WIDTH = 60
@ -43,15 +45,13 @@ class Smieciarka(pygame.sprite.Sprite):
if self.x > 0:
if game.plansza[self.x - 1, self.y].jestPrzeszkoda is not True:
self.x -= 1
game.plansza[self.x,self.y].setKolor(BLUE)
game.plansza[self.x, self.y].setKolor(BLUE)
self.rect.x = MARGIN + self.x * WIDTH + self.x * MARGIN
if self.ruch == 2:
self.image = pygame.image.load(
'resources/plansza/smieciarka.png')
self.ruch = 1
def w_prawo(self):
if self.x < 14:
if game.plansza[self.x + 1, self.y].jestPrzeszkoda is not True:
@ -62,7 +62,6 @@ class Smieciarka(pygame.sprite.Sprite):
self.image = pygame.transform.flip(self.image, True, False)
self.ruch = 2
def w_gore(self):
if self.y > 0:
if game.plansza[self.x, self.y - 1].jestPrzeszkoda is not True:
@ -70,7 +69,6 @@ class Smieciarka(pygame.sprite.Sprite):
game.plansza[self.x, self.y].setKolor(BLUE)
self.rect.y = self.y * HEIGHT + self.y * MARGIN
def w_dol(self):
if self.y < 14:
if game.plansza[self.x, self.y + 1].jestPrzeszkoda is not True:
@ -140,3 +138,29 @@ class Kratka(pygame.sprite.Sprite):
def setKolor(self, kolor):
self.kolor = kolor
def generujWspolrzedneDomow():
unikalne = False
wspolrzedne_domow = np.array([[0 for i in range(2)] for j in range(15)])
while not unikalne:
for i in range(15):
wspolrzedne_domow[i, 0] = random.randrange(15)
if wspolrzedne_domow[i, 0] < 5:
wspolrzedne_domow[i, 1] = random.randrange(5, 15)
else:
wspolrzedne_domow[i, 1] = random.randrange(0, 15)
wspolrzedne_domow = np.unique(wspolrzedne_domow, axis=0)
j = 0
while True:
if j >= len(wspolrzedne_domow):
break
if np.sum(wspolrzedne_domow[j, 0] == wspolrzedne_domow[:, 0]) > 1:
wspolrzedne_domow = np.delete(wspolrzedne_domow, j, axis=0)
else:
j += 1
if len(wspolrzedne_domow) > 5:
unikalne = True
return wspolrzedne_domow

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB