Working on getting falled brick to stay in place. /JL

This commit is contained in:
2025-04-29 20:41:24 +02:00
parent ce48cb2936
commit 89e55ab3b0
2 changed files with 12 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ from enums import BrickColor
class DropZone():
def __init__(self, width, height):
self.dropzone = pygame.Surface((width * globals.TILE_SIZE, height * globals.TILE_SIZE))
#self.dropzone.fill(BrickColor.Black.value)
self.width = width
self.height = height
@@ -14,3 +15,12 @@ class DropZone():
def draw_brick(self, brick, location):
self.dropzone.fill(BrickColor.Black.value)
self.dropzone.blit(brick, (location[0] * globals.TILE_SIZE, location[1] * globals.TILE_SIZE))
def lock(self, brick):
for row_idx, row in enumerate(brick.shape):
for col_idx, cell in enumerate(row):
if cell:
globals.dropgrid[brick.y + row_idx][brick.x + col_idx] = 1
self.dropzone.blit(brick.brick, (brick.y + row_idx, brick.x + col_idx))