Reworked weight in surface

This commit is contained in:
HelQ 2022-06-04 18:10:23 +02:00
parent 21b2510a4f
commit 1815ff2919
2 changed files with 14 additions and 11 deletions

View File

@ -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 = []

View File

@ -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')