Mowing toward numpy for grid and bricks. /JL

This commit is contained in:
2025-05-10 14:59:00 +02:00
parent 93e433fc1b
commit a349da2a58
3 changed files with 6 additions and 4 deletions

View File

@@ -21,7 +21,7 @@ class DropZone():
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
globals.grid[brick.y + row_idx][brick.x + col_idx] = 1
self.dropzone.blit(brick.brick, (brick.y + row_idx, brick.x + col_idx))

View File

@@ -1,3 +1,3 @@
numpy==2.2.5
pygame==2.6.1
pygamecontrols==0.2.2
pygamecontrols==0.2.5

View File

@@ -100,7 +100,7 @@ class Tetris:
case pygame.QUIT:
self.running = False
case pygame.KEYDOWN:
new_pos = pos[:]
#new_pos = pos[:]
match event.key:
case pygame.K_RIGHT:
if self.current.direction == enums.BrickDirection.Dropped:
@@ -193,7 +193,7 @@ class Tetris:
if not self.current.update():
self.dropzone.lock(self.current)
self.current = self.next
self.next = Brick(brick = randrange(0, len(BRICKS)))
self.next = Brick(brick = random.choice(list(BRICKS.keys())))
# Handle hotplugging
case pygame.JOYDEVICEADDED:
@@ -217,9 +217,11 @@ class Tetris:
if "left button" in self.joysticks[self.joy.get_instance_id()].controllers[0].mapping:
self.left_button = self.joysticks[self.joy.get_instance_id()].controllers[0].mapping["left button"]
else: self.left_button = None
if "right button" in self.joysticks[self.joy.get_instance_id()].controllers[0].mapping:
self.right_button = self.joysticks[self.joy.get_instance_id()].controllers[0].mapping["right button"]
else: self.right_button = None
case pygame.JOYDEVICEREMOVED:
del self.joysticks[event.instance_id]