AI_PROJECT/Slot.py

47 lines
1.6 KiB
Python
Raw Permalink Normal View History

2024-03-10 15:03:56 +01:00
import pygame
import displayControler as dCon
import Colors
import random
import Image
import Roslina
2024-03-10 15:03:56 +01:00
BORDER_THICKNESS=1 #Has to be INT value
class Slot:
def __init__(self,x_axis,y_axis,color,screen,image_loader):
2024-03-10 15:03:56 +01:00
self.x_axis=x_axis
self.y_axis=y_axis
2024-03-23 21:00:08 +01:00
self.plant_image = None
self.plant=None
2024-03-10 15:03:56 +01:00
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
2024-03-10 15:03:56 +01:00
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
2024-03-10 15:03:56 +01:00
pygame.display.update()
def redraw_image(self):
self.set_image()
2024-03-10 15:03:56 +01:00
def color_change(self,color):
self.plant=color
2024-03-10 15:03:56 +01:00
self.draw()
def set_random_plant(self):
(plant_name,self.plant_image)=self.random_plant()
self.plant=Roslina.Roslina(plant_name)
self.set_image()
def set_image(self):
2024-03-23 21:00:08 +01:00
if self.plant_image is None:
self.plant_image = self.image_loader.return_random_plant()
self.screen.blit(self.plant_image, (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()
def print_status(self):
return f"wspolrzedne: (X:{self.x_axis} Y:{self.y_axis}) "+self.plant.report_status()