55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
import random
|
|
import time
|
|
import os
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
from PIL import Image
|
|
|
|
# path to plant images folder (used in randomize_photo function)
|
|
folder_path = "resources/images/plant_photos"
|
|
|
|
|
|
class Tile:
|
|
x = 0
|
|
y = 0
|
|
plant = None
|
|
ground = None
|
|
|
|
photo = None
|
|
image = None
|
|
|
|
# after checking a photo add information plant object ("potato"/ "wheat"/"none")
|
|
|
|
# add Ground instance
|
|
|
|
def __init__(self, x, y):
|
|
self.x = x
|
|
self.y = y
|
|
|
|
# add to init ground instance
|
|
|
|
# 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.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"
|
|
ground = self.ground
|
|
if ground.obstacle and self.x != 170 and self.y != 100: #warunek po and do zmiany
|
|
self.image = "resources/images/rock_dirt.png"
|
|
|
|
|