From 592281ea2bc7e582fa805e81b71c36c2cec8d616 Mon Sep 17 00:00:00 2001 From: tonywesoly Date: Wed, 20 Apr 2022 18:27:24 +0200 Subject: [PATCH] Przeniesienie zmiennych globalnych do osobnej klasy --- Shelf.py | 10 ++++------ Truck.py | 12 +++++------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Shelf.py b/Shelf.py index 8d22503..a6dfb5c 100644 --- a/Shelf.py +++ b/Shelf.py @@ -1,17 +1,15 @@ import pygame -RECT_SIZE = 50 -SHELF_COLOR = (143, 68, 33) - +from Global_variables import Global_variables as G_var class Shelf: def __init__(self, window, x, y): self.window = window - self.width = RECT_SIZE - self.length = 6*RECT_SIZE + self.width = G_var().RECT_SIZE + self.length = 6*G_var().RECT_SIZE self.x = x self.y = y self.block = pygame.Rect(self.x, self.y, self.width, self.length) def draw(self): - pygame.draw.rect(self.window, SHELF_COLOR, self.block) + pygame.draw.rect(self.window, G_var().SHELF_COLOR, self.block) # pygame.draw.line(self.window, (255, 255, 255), (self.x, self.y), (self.x, self.y + self.length)) diff --git a/Truck.py b/Truck.py index a3ce7d2..bd03a60 100644 --- a/Truck.py +++ b/Truck.py @@ -1,9 +1,7 @@ - import pygame from Environment import Environment from Package import Package -RECT_SIZE = 50 - +from Global_variables import Global_variables as G_var class Truck: def __init__(self, window, ): @@ -25,19 +23,19 @@ class Truck: # moving the truck def move_right(self): - self.x += RECT_SIZE + self.x += G_var().RECT_SIZE self.draw() def move_left(self): - self.x -= RECT_SIZE + self.x -= G_var().RECT_SIZE self.draw() def move_up(self): - self.y -= RECT_SIZE + self.y -= G_var().RECT_SIZE self.draw() def move_down(self): - self.y += RECT_SIZE + self.y += G_var().RECT_SIZE self.draw() # def collision_with_shelves(self,x,y):