diff --git a/App.py b/App.py index 6a994a7..2a7bc1e 100644 --- a/App.py +++ b/App.py @@ -74,11 +74,14 @@ def demo_move(): traktor.random_move(pole) def get_info(old_info): - (x,y)=pygame.mouse.get_pos() - new_info=pole.check_collision(x,y) - if(old_info!=new_info): - print(new_info) - return new_info + try: + (x,y)=pygame.mouse.get_pos() + new_info=pole.check_collision(x,y) + if(old_info!=new_info): + print(new_info) + return new_info + except: + pass diff --git a/Image.py b/Image.py index 4bd8136..a924bd0 100644 --- a/Image.py +++ b/Image.py @@ -6,6 +6,7 @@ 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", @@ -19,6 +20,8 @@ class Image: 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()) @@ -26,4 +29,7 @@ class Image: return (plant,self.plants_image_dict[plant]) def return_plant(self,plant_name): - return (plant_name,self.plants_image_dict[plant_name]) \ No newline at end of file + return (plant_name,self.plants_image_dict[plant_name]) + + def return_garage(self): + return self.garage_image \ No newline at end of file diff --git a/Pole.py b/Pole.py index 983dbf9..dc7d82e 100644 --- a/Pole.py +++ b/Pole.py @@ -33,13 +33,18 @@ class Pole: slot_dict=self.get_slot_dict() for coordinates in slot_dict: slot_dict[coordinates].draw() + garage=self.slot_dict[(0,0)] + garage.set_garage_image() def randomize_colors(self): pygame.display.update() time.sleep(3) self.ui.render_text("Randomizing Crops") for coordinates in self.slot_dict: - self.slot_dict[coordinates].set_random_plant() + if(coordinates==(0,0)): + continue + else: + self.slot_dict[coordinates].set_random_plant() def change_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) self.get_slot_from_cord(coordinates).color_change(color) diff --git a/Slot.py b/Slot.py index 262ee12..15511dc 100644 --- a/Slot.py +++ b/Slot.py @@ -15,6 +15,7 @@ class Slot: 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 + self.garage_image=None def draw(self): pygame.draw.rect(self.screen,Colors.BROWN,self.field,0) #Draw field @@ -39,6 +40,11 @@ class Slot: 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 set_garage_image(self): + self.plant_image=self.image_loader.return_garage() + 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() diff --git a/Tractor.py b/Tractor.py index 74c8645..2c0dfe3 100644 --- a/Tractor.py +++ b/Tractor.py @@ -155,5 +155,8 @@ class Tractor: else: print("Brak akcji przypisanych do tego sprzętu.") def irrigateSlot(self): - self.slot.irrigatePlant() + try: + self.slot.irrigatePlant() + except: + pass diff --git a/images/garage.png b/images/garage.png new file mode 100644 index 0000000..f9ca1c0 Binary files /dev/null and b/images/garage.png differ