fix: remove randomization of rotation

This commit is contained in:
2021-06-04 11:31:39 -04:00
parent ca10062912
commit 8f519b5ab7
3 changed files with 12 additions and 15 deletions

View File

@@ -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

22
main.py
View File

@@ -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,15 +53,18 @@ 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])

View File

@@ -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():