From 1815ff2919e3ea828b60e291904af3f8391d285f Mon Sep 17 00:00:00 2001 From: HelQ Date: Sat, 4 Jun 2022 18:10:23 +0200 Subject: [PATCH] Reworked weight in surface --- main.py | 6 +++--- surface.py | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index 8d14361..f3f31a8 100644 --- a/main.py +++ b/main.py @@ -32,11 +32,11 @@ surface_list = [] for i in range(15): for j in range(15): if matrix[i][j] == 1: - surface_list.append(Grass(screen, j * 60, i * 60, 1)) + surface_list.append(Grass(screen, j * 60, i * 60)) if matrix[i][j] == 2: - surface_list.append(Rock(screen, j * 60, i * 60, 2)) + surface_list.append(Rock(screen, j * 60, i * 60)) if matrix[i][j] == 3: - surface_list.append(Water(screen, j * 60, i * 60, 3)) + surface_list.append(Water(screen, j * 60, i * 60)) run = 1 path = [] diff --git a/surface.py b/surface.py index f7b5955..f9ebc76 100644 --- a/surface.py +++ b/surface.py @@ -3,11 +3,11 @@ import pygame class Surface: - def __init__(self, screen, x, y, weight): + def __init__(self, screen, x, y): self.state = (x, y) self.x = x self.y = y - self.weight = weight + self.weight = 0 self.screen = screen self.image = pygame.image.load('images/grass.png') self.surface_rect = self.image.get_rect() @@ -19,20 +19,23 @@ class Surface: class Grass(Surface): - def __init__(self, screen, x, y, weight): - super().__init__(screen, x, y, weight) + def __init__(self, screen, x, y): + super().__init__(screen, x, y) + self.weight = 1 self.image = pygame.image.load('images/grass.png') class Rock(Surface): - def __init__(self, screen, x, y, weight): - super().__init__(screen, x, y, weight) + def __init__(self, screen, x, y): + super().__init__(screen, x, y) + self.weight = 2 self.image = pygame.image.load('images/rock.png') class Water(Surface): - def __init__(self, screen, x, y, weight): - super().__init__(screen, x, y, weight) + def __init__(self, screen, x, y): + super().__init__(screen, x, y) + self.weight = 3 self.image = pygame.image.load('images/water.png')