2024-03-07 18:01:12 +01:00
|
|
|
import random
|
2024-05-27 05:28:48 +02:00
|
|
|
import time
|
2024-03-07 23:03:52 +01:00
|
|
|
import os
|
2024-05-26 19:54:46 +02:00
|
|
|
import numpy as np
|
|
|
|
import matplotlib.pyplot as plt
|
2024-05-26 23:28:22 +02:00
|
|
|
from PIL import Image
|
2024-03-07 23:03:52 +01:00
|
|
|
|
2024-03-22 22:14:05 +01:00
|
|
|
# path to plant images folder (used in randomize_photo function)
|
2024-04-27 22:49:47 +02:00
|
|
|
folder_path = "resources/images/plant_photos"
|
2024-03-07 23:03:52 +01:00
|
|
|
|
2024-03-07 18:01:12 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2024-03-22 22:14:05 +01:00
|
|
|
# choose random photo from the folder:
|
2024-03-07 23:03:52 +01:00
|
|
|
|
|
|
|
def randomize_photo(self):
|
|
|
|
random_photo = random.choice(os.listdir(folder_path))
|
|
|
|
photo_path = os.path.join(folder_path, random_photo)
|
|
|
|
return photo_path
|
|
|
|
|
2024-03-07 18:01:12 +01:00
|
|
|
def randomizeContent(self):
|
2024-03-07 23:03:52 +01:00
|
|
|
photo_path = self.randomize_photo()
|
2024-03-23 22:54:51 +01:00
|
|
|
i = random.randint(1, 3) # szansa 1/3
|
2024-03-07 18:01:12 +01:00
|
|
|
if i == 1:
|
|
|
|
self.image = "resources/images/sampling.png"
|
2024-03-07 23:03:52 +01:00
|
|
|
self.photo = photo_path
|
2024-03-22 22:14:05 +01:00
|
|
|
# self.photo losuje dodatkowo zdjecie jakies rosliny do danego rzędu
|
2024-03-07 18:01:12 +01:00
|
|
|
else:
|
|
|
|
self.image = "resources/images/dirt.png"
|
2024-03-07 23:03:52 +01:00
|
|
|
self.photo = "resources/images/background.jpg"
|
2024-04-14 23:19:06 +02:00
|
|
|
ground = self.ground
|
2024-04-14 23:45:41 +02:00
|
|
|
if ground.obstacle and self.x != 170 and self.y != 100: #warunek po and do zmiany
|
2024-04-14 23:19:06 +02:00
|
|
|
self.image = "resources/images/rock_dirt.png"
|
|
|
|
|
2024-03-07 18:01:12 +01:00
|
|
|
|