diff --git a/entity/Well.py b/entity/Well.py index e40f6bb..7bb44f9 100644 --- a/entity/Well.py +++ b/entity/Well.py @@ -2,7 +2,7 @@ import pygame from util.ConfigurationManager import ConfigurationManager -class Well: +class Well: # TODO game objects base class / interface? WIDTH = 10 # standard tetris well width, should not be changed HEIGHT = 20 # standard tetris well height, should not be changed diff --git a/main.py b/main.py index 2495ccd..1e02bc9 100644 --- a/main.py +++ b/main.py @@ -40,14 +40,9 @@ def main(): pygame.display.set_caption(win_title) pygame.display.set_icon(loaded_icon) - pieces = [] + current_piece = PieceGenerator.get_piece((300, 100)) + pieces = [current_piece] well = Well((280, 80)) - x = 50 - y = 50 - for _ in range(6): - pieces.append(PieceGenerator.get_piece((x, y))) - x += 120 - y += 100 is_running = True while is_running: @@ -58,16 +53,19 @@ def main(): is_running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_SPACE: - [piece.rotate() for piece in pieces] + current_piece.rotate() if event.key == pygame.K_LEFT: - [piece.move((-tile_size, 0)) for piece in pieces] + current_piece.move((-tile_size, 0)) if event.key == pygame.K_RIGHT: - [piece.move((tile_size, 0)) for piece in pieces] + current_piece.move((tile_size, 0)) if event.key == pygame.K_UP: - [piece.move((0, -tile_size)) for piece in pieces] + current_piece.move((0, -tile_size)) if event.key == pygame.K_DOWN: - [piece.move((0, tile_size)) for piece in pieces] - + current_piece.move((0, tile_size)) + if event.key == pygame.K_z: + current_piece = PieceGenerator.get_piece((300, 100)) + pieces.append(current_piece) + draw(screen, pieces + [well]) pygame.quit() diff --git a/util/PieceGenerator.py b/util/PieceGenerator.py index 2b6c2e1..876e847 100644 --- a/util/PieceGenerator.py +++ b/util/PieceGenerator.py @@ -8,7 +8,6 @@ class PieceGenerator: @classmethod def get_piece(cls, position): piece = Piece(cls.__get_piece_shape(), position, cls.__get_piece_color()) - [piece.rotate() for _ in range(random.randint(0, 3))] # randomize rotated position return piece def __get_piece_shape():