AI_PROJECT/Image.py

35 lines
1.3 KiB
Python

import pygame
import displayControler as dCon
import random
class Image:
def __init__(self):
self.plants_image_dict={}
self.tractor_image=None
self.garage_image=None
def load_images(self):
files_plants={0:"borowka",
1:"kukurydza",
2:"pszenica",
3:"slonecznik",
4:"winogrono",
5:"ziemniak"}
for index in files_plants:
plant_image=pygame.image.load("images/plants/"+files_plants[index]+".jpg")
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))
garage=pygame.image.load("images/garage.png")
self.garage_image=pygame.transform.scale(garage,(dCon.CUBE_SIZE,dCon.CUBE_SIZE))
def return_random_plant(self):
x=random.randint(0,5)
keys=list(self.plants_image_dict.keys())
plant=keys[x]
return (plant,self.plants_image_dict[plant])
def return_plant(self,plant_name):
return (plant_name,self.plants_image_dict[plant_name])
def return_garage(self):
return self.garage_image