AI_PROJECT/Slot.py

41 lines
1.3 KiB
Python

import pygame
import displayControler as dCon
import Colors
import random
import Image
BORDER_THICKNESS=1 #Has to be INT value
class Slot:
def __init__(self,x_axis,y_axis,color,screen,image_loader):
self.x_axis=x_axis
self.y_axis=y_axis
self.plant=color #TODO CHANGE IT BY HOOKING PLANT CLASS
self.condition=""#TODO HOOK CONDITION CLASS NOW COMPLETLY UNUSED
self.screen=screen
self.field=pygame.Rect(self.x_axis*dCon.CUBE_SIZE,self.y_axis*dCon.CUBE_SIZE,dCon.CUBE_SIZE,dCon.CUBE_SIZE)
self.image_loader=image_loader
def draw(self):
pygame.draw.rect(self.screen,Colors.BROWN,self.field,0) #Draw field
pygame.draw.rect(self.screen,Colors.BLACK,self.field,BORDER_THICKNESS) #Draw border
pygame.display.update()
def redraw_image(self):
self.set_image()
def color_change(self,color):
self.plant=color
self.draw()
def set_random_plant(self):
self.plant=self.random_plant()
self.set_image()
def set_image(self):
self.screen.blit(self.plant,(self.x_axis*dCon.CUBE_SIZE,self.y_axis*dCon.CUBE_SIZE))
pygame.draw.rect(self.screen,Colors.BLACK,self.field,BORDER_THICKNESS)
def random_plant(self): #Probably will not be used later only for demo purpouse
return self.image_loader.return_random_plant()