2024-03-23 13:46:48 +01:00
|
|
|
import pygame
|
|
|
|
import displayControler as dCon
|
|
|
|
import random
|
|
|
|
|
|
|
|
class Image:
|
|
|
|
def __init__(self):
|
|
|
|
self.plants_image_dict={}
|
|
|
|
self.tractor_image=None
|
2024-04-15 10:02:09 +02:00
|
|
|
self.garage_image=None
|
2024-04-24 22:16:34 +02:00
|
|
|
self.stone_image=None
|
2024-04-27 00:59:48 +02:00
|
|
|
self.gasStation_image=None
|
2024-03-23 13:46:48 +01:00
|
|
|
def load_images(self):
|
2024-04-27 00:59:48 +02:00
|
|
|
files_plants={
|
|
|
|
0:"borowka",
|
2024-03-23 13:46:48 +01:00
|
|
|
1:"kukurydza",
|
|
|
|
2:"pszenica",
|
|
|
|
3:"slonecznik",
|
|
|
|
4:"winogrono",
|
2024-04-24 22:16:34 +02:00
|
|
|
5:"ziemniak",
|
|
|
|
6:"dirt",
|
2024-04-28 12:58:58 +02:00
|
|
|
7:"mud",
|
|
|
|
8:"road"}
|
2024-03-23 13:46:48 +01:00
|
|
|
for index in files_plants:
|
2024-04-24 22:16:34 +02:00
|
|
|
if index >= 6:
|
|
|
|
plant_image = pygame.image.load("images/" + files_plants[index] + ".jpg")
|
|
|
|
else:
|
|
|
|
plant_image=pygame.image.load("images/plants/"+files_plants[index]+".jpg")
|
2024-03-23 13:46:48 +01:00
|
|
|
plant_image=pygame.transform.scale(plant_image,(dCon.CUBE_SIZE,dCon.CUBE_SIZE))
|
|
|
|
self.plants_image_dict[files_plants[index]]=plant_image
|
|
|
|
tractor_image=pygame.image.load("images/traktor.png")
|
|
|
|
tractor_image=pygame.transform.scale(tractor_image,(dCon.CUBE_SIZE,dCon.CUBE_SIZE))
|
2024-04-15 10:02:09 +02:00
|
|
|
garage=pygame.image.load("images/garage.png")
|
|
|
|
self.garage_image=pygame.transform.scale(garage,(dCon.CUBE_SIZE,dCon.CUBE_SIZE))
|
2024-04-24 22:16:34 +02:00
|
|
|
stone=pygame.image.load("images/stone.png")
|
|
|
|
self.stone_image=pygame.transform.scale(stone,(dCon.CUBE_SIZE,dCon.CUBE_SIZE))
|
2024-04-27 00:59:48 +02:00
|
|
|
gasStation=pygame.image.load("images/gasStation.png")
|
|
|
|
self.gasStation_image=pygame.transform.scale(gasStation,(dCon.CUBE_SIZE,dCon.CUBE_SIZE))
|
2024-04-24 22:16:34 +02:00
|
|
|
|
2024-03-23 13:46:48 +01:00
|
|
|
def return_random_plant(self):
|
2024-05-11 14:18:40 +02:00
|
|
|
x=random.randint(0,5) #disabled dirt and mud generation
|
2024-03-23 13:46:48 +01:00
|
|
|
keys=list(self.plants_image_dict.keys())
|
|
|
|
plant=keys[x]
|
2024-03-24 23:30:02 +01:00
|
|
|
return (plant,self.plants_image_dict[plant])
|
2024-03-23 13:59:24 +01:00
|
|
|
|
|
|
|
def return_plant(self,plant_name):
|
2024-04-15 10:02:09 +02:00
|
|
|
return (plant_name,self.plants_image_dict[plant_name])
|
|
|
|
|
|
|
|
def return_garage(self):
|
2024-04-24 22:16:34 +02:00
|
|
|
return self.garage_image
|
|
|
|
|
|
|
|
def return_stone(self):
|
|
|
|
return self.stone_image
|
2024-04-27 00:59:48 +02:00
|
|
|
|
|
|
|
def return_gasStation(self):
|
|
|
|
return self.gasStation_image
|