self.slot_dict={}#Slot are stored in dictionary with key being a Tuple of x and y coordinates so top left slot key is (0,0) and value is slot object
self.ui=Ui.Ui(screen)
self.image_loader=image_loader
defget_slot_from_cord(self,coordinates):
(x_axis,y_axis)=coordinates
returnself.slot_dict[(x_axis,y_axis)]
defset_slot(self,coodrinates,slot):#set slot in these coordinates
(x_axis,y_axis)=coodrinates
self.slot_dict[(x_axis,y_axis)]=slot
defget_slot_dict(self):#returns whole slot_dict
returnself.slot_dict
#Draw grid and tractor (new one)
defdraw_grid(self):
forxinrange(0,dCon.NUM_X):#Draw all cubes in X axis
foryinrange(0,dCon.NUM_Y):#Draw all cubes in Y axis
new_slot=Slot.Slot(x,y,Colors.BROWN,self.screen,self.image_loader)#Creation of empty slot
self.set_slot((x,y),new_slot)#Adding slots to dict
slot_dict=self.get_slot_dict()
forcoordinatesinslot_dict:
slot_dict[coordinates].draw()
defrandomize_colors(self):
pygame.display.update()
time.sleep(3)
self.ui.render_text("Randomizing Crops")
forcoordinatesinself.slot_dict:
self.slot_dict[coordinates].set_random_plant()
defchange_color_of_slot(self,coordinates,color):#Coordinates must be tuple (x,y) (left top slot has cord (0,0) ), color has to be from defined in Colors.py or custom in RGB value (R,G,B)