Merge pull request 'Working on getting falled brick to stay in place. /JL' (#8) from 0.1.2 into main
Reviewed-on: https://gitpot-lerking.servehttp.com/CodingPirates/PyGame-Tetris/pulls/8
This commit was merged in pull request #8.
This commit is contained in:
10
dropzone.py
10
dropzone.py
@@ -5,6 +5,7 @@ from enums import BrickColor
|
|||||||
class DropZone():
|
class DropZone():
|
||||||
def __init__(self, width, height):
|
def __init__(self, width, height):
|
||||||
self.dropzone = pygame.Surface((width * globals.TILE_SIZE, height * globals.TILE_SIZE))
|
self.dropzone = pygame.Surface((width * globals.TILE_SIZE, height * globals.TILE_SIZE))
|
||||||
|
#self.dropzone.fill(BrickColor.Black.value)
|
||||||
self.width = width
|
self.width = width
|
||||||
self.height = height
|
self.height = height
|
||||||
|
|
||||||
@@ -14,3 +15,12 @@ class DropZone():
|
|||||||
def draw_brick(self, brick, location):
|
def draw_brick(self, brick, location):
|
||||||
self.dropzone.fill(BrickColor.Black.value)
|
self.dropzone.fill(BrickColor.Black.value)
|
||||||
self.dropzone.blit(brick, (location[0] * globals.TILE_SIZE, location[1] * globals.TILE_SIZE))
|
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))
|
||||||
|
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ from dropzone import DropZone
|
|||||||
from dropnext import DropNext
|
from dropnext import DropNext
|
||||||
from hud import Hud
|
from hud import Hud
|
||||||
|
|
||||||
__version__ = "0.1.1"
|
__version__ = "0.1.2"
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
HAT_REPEAT_DELAY = 0 # milliseconds before first repeat
|
HAT_REPEAT_DELAY = 0 # milliseconds before first repeat
|
||||||
@@ -178,6 +178,7 @@ class Tetris:
|
|||||||
|
|
||||||
case self.fall_timer:
|
case self.fall_timer:
|
||||||
if not self.current.update():
|
if not self.current.update():
|
||||||
|
self.dropzone.lock(self.current)
|
||||||
self.current = self.next
|
self.current = self.next
|
||||||
self.next = Brick(brick = randrange(0, len(BRICKS)))
|
self.next = Brick(brick = randrange(0, len(BRICKS)))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user