Files
PyGame-Tetris/dropzone.py

27 lines
982 B
Python

import pygame
import numpy as np
import globals
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
def draw(self, screen):
screen.blit(self.dropzone, (globals.TILE_SIZE * 4, globals.TILE_SIZE * 1))
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.grid[brick.y + row_idx][brick.x + col_idx] = 1
self.dropzone.blit(brick.brick, (brick.y + row_idx, brick.x + col_idx))