mirror of
https://github.com/kristoferssolo/Tetris.git
synced 2025-10-21 20:00:35 +00:00
feat(game): add vertical borders
style(game): rename method style(game): wrong method name style(game): fix wrong method name
This commit is contained in:
parent
684f5ba196
commit
d28f24cf0a
@ -15,3 +15,6 @@ class Block(pygame.sprite.Sprite):
|
|||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
self.rect.topleft = self.pos * CONFIG.game.cell.width
|
self.rect.topleft = self.pos * CONFIG.game.cell.width
|
||||||
|
|
||||||
|
def vertical_collision(self, x: int) -> bool:
|
||||||
|
return not 0 <= x < CONFIG.game.columns
|
||||||
|
|||||||
@ -24,9 +24,14 @@ class Tetromino:
|
|||||||
block.pos.y += 1
|
block.pos.y += 1
|
||||||
|
|
||||||
def move_horizontal(self, direction: Direction) -> None:
|
def move_horizontal(self, direction: Direction) -> None:
|
||||||
|
if not self._check_vertical_collision(self.blocks, direction):
|
||||||
for block in self.blocks:
|
for block in self.blocks:
|
||||||
block.pos.x += direction.value
|
block.pos.x += direction.value
|
||||||
|
|
||||||
def next_move_horizontal_collide(self, block: Block, direction: Direction) -> None:
|
def _check_vertical_collision(
|
||||||
for block in self.blocks:
|
self, blocks: list[Block], direction: Direction
|
||||||
block.pos.x += direction.value
|
) -> bool:
|
||||||
|
return any(
|
||||||
|
block.vertical_collision(int(block.pos.x + direction.value))
|
||||||
|
for block in self.blocks
|
||||||
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user