Wände angepasst: Konstruktor der Wall-Klasse geändert, um Spalten und Reihen zu verwenden, und die Wandpositionen im Spiel aktualisiert.
This commit is contained in:
parent
d7f2b54f3b
commit
d80e8391cb
2 changed files with 19 additions and 25 deletions
10
game.py
10
game.py
|
|
@ -41,13 +41,13 @@ class Game:
|
||||||
game=self,
|
game=self,
|
||||||
items=[],
|
items=[],
|
||||||
walls=[
|
walls=[
|
||||||
Wall(self, 0, 0, SCREEN_WIDTH, TILE_SIZE),
|
Wall(self, 0, 0, SCREEN_WIDTH//TILE_SIZE, 1),
|
||||||
Wall(self, 0, TILE_SIZE, TILE_SIZE, SCREEN_HEIGHT),
|
Wall(self, 0, TILE_SIZE, 1, SCREEN_HEIGHT//TILE_SIZE),
|
||||||
Wall(
|
Wall(
|
||||||
self, TILE_SIZE, SCREEN_HEIGHT - TILE_SIZE, SCREEN_WIDTH, TILE_SIZE
|
self, TILE_SIZE, SCREEN_HEIGHT - TILE_SIZE, SCREEN_WIDTH//TILE_SIZE, 1
|
||||||
),
|
),
|
||||||
Wall(self, SCREEN_WIDTH - TILE_SIZE, 0, SCREEN_WIDTH, SCREEN_HEIGHT),
|
Wall(self, SCREEN_WIDTH - TILE_SIZE, 0, SCREEN_WIDTH//TILE_SIZE, SCREEN_HEIGHT//TILE_SIZE),
|
||||||
Wall(self, 500, 500, 128, 128)
|
Wall(self, 500, 500, 2, 2)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,35 +4,29 @@ from scripts.constants import *
|
||||||
|
|
||||||
|
|
||||||
class Wall:
|
class Wall:
|
||||||
def __init__(self, game, x: float, y: float, width: float, height: float):
|
def __init__(self, game, x: float, y: float, cols: int, rows: int):
|
||||||
self.game = game
|
self.game = game
|
||||||
self.x = x
|
self.x = x
|
||||||
self.y = y
|
self.y = y
|
||||||
self.width = width
|
self.cols = cols
|
||||||
self.height = height
|
self.rows = rows
|
||||||
self.rect = pygame.Rect(x, y, width, height)
|
self.rect = pygame.Rect(x, y, cols*TILE_SIZE, rows*TILE_SIZE)
|
||||||
|
self.drawed_rect = None
|
||||||
|
self.grid: list[list[pygame.Rect]] = []
|
||||||
|
|
||||||
for i in range(self.width):
|
|
||||||
if i % 64 == 0:
|
|
||||||
end_ergebnis_width = i
|
|
||||||
|
|
||||||
for i in range(self.height):
|
for row in range(self.rows): # rows
|
||||||
if i % 64 == 0:
|
current_row = []
|
||||||
end_ergebnis_height = i
|
for col in range(self.cols): # cols
|
||||||
|
current_row.append(pygame.Rect(col*TILE_SIZE, row*TILE_SIZE, TILE_SIZE, TILE_SIZE))
|
||||||
|
|
||||||
self.length: dict = {
|
self.grid.append(current_row)
|
||||||
"width": end_ergebnis_width+TILE_SIZE,
|
|
||||||
"height": end_ergebnis_height+TILE_SIZE,
|
|
||||||
}
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def render(self, surface: pygame.Surface):
|
def render(self, surface: pygame.Surface):
|
||||||
for x in range(self.length["width"]):
|
pass
|
||||||
for y in range(self.length["height"]):
|
|
||||||
if y % TILE_SIZE == 0 and x % TILE_SIZE == 0:
|
|
||||||
surface.blit(self.game.assets["wall"], pygame.Rect(self.x+x, self.y+y, self.width, self.height))
|
|
||||||
|
|
||||||
def get_rect(self) -> pygame.Rect:
|
def get_rect(self) -> pygame.Rect:
|
||||||
return self.rect
|
return self.rect
|
||||||
Loading…
Reference in a new issue