added random selection of photos for Tiles
This commit is contained in:
parent
56ae2c85de
commit
c0fdc3dcf2
BIN
source/__pycache__/tile.cpython-311.pyc
Normal file
BIN
source/__pycache__/tile.cpython-311.pyc
Normal file
Binary file not shown.
BIN
source/area/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
source/area/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
source/area/__pycache__/constants.cpython-311.pyc
Normal file
BIN
source/area/__pycache__/constants.cpython-311.pyc
Normal file
Binary file not shown.
BIN
source/area/__pycache__/field.cpython-311.pyc
Normal file
BIN
source/area/__pycache__/field.cpython-311.pyc
Normal file
Binary file not shown.
BIN
source/area/__pycache__/tractor.cpython-311.pyc
Normal file
BIN
source/area/__pycache__/tractor.cpython-311.pyc
Normal file
Binary file not shown.
@ -24,6 +24,7 @@ def createTiles():
|
||||
for y in range (0,COLS):
|
||||
for x in range (0,ROWS):
|
||||
tile = Tile(x*TILE_SIZE, y*TILE_SIZE)
|
||||
tile.randomize_photo()
|
||||
tile.randomizeContent()
|
||||
tiles.append(tile)
|
||||
positionFieldElements()
|
||||
|
BIN
source/resources/images/background.jpg
Normal file
BIN
source/resources/images/background.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 MiB |
BIN
source/resources/images/plant_photos/pexels-dxt-73640.jpg
Normal file
BIN
source/resources/images/plant_photos/pexels-dxt-73640.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 MiB |
Binary file not shown.
After Width: | Height: | Size: 341 KiB |
BIN
source/resources/images/plant_photos/pexels-pixabay-144248.jpg
Normal file
BIN
source/resources/images/plant_photos/pexels-pixabay-144248.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 MiB |
Binary file not shown.
After Width: | Height: | Size: 305 KiB |
@ -1,4 +1,9 @@
|
||||
import random
|
||||
import os
|
||||
|
||||
#path to plant images folder (used in randomize_photo function)
|
||||
folder_path = "resources\images\plant_photos"
|
||||
|
||||
|
||||
class Tile:
|
||||
x = 0
|
||||
@ -21,14 +26,23 @@ class Tile:
|
||||
|
||||
# called on a created tile
|
||||
|
||||
#choose random photo from the folder:
|
||||
|
||||
def randomize_photo(self):
|
||||
random_photo = random.choice(os.listdir(folder_path))
|
||||
photo_path = os.path.join(folder_path, random_photo)
|
||||
return photo_path
|
||||
|
||||
def randomizeContent(self):
|
||||
photo_path = self.randomize_photo()
|
||||
i = random.randint(1, 3) #szansa 1/3
|
||||
if i == 1:
|
||||
self.image = "resources/images/sampling.png"
|
||||
#self.picture losuje dodatkowo zdjecie jakies rosliny do danego rzędu
|
||||
self.photo = photo_path
|
||||
#self.photo losuje dodatkowo zdjecie jakies rosliny do danego rzędu
|
||||
else:
|
||||
self.image = "resources/images/dirt.png"
|
||||
|
||||
self.photo = "resources/images/background.jpg"
|
||||
|
||||
# DISCLAMER check column and choose plant type ("potato","wheat" etc)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user