fix: remove randomization of rotation
This commit is contained in:
@@ -2,7 +2,7 @@ import pygame
|
|||||||
|
|
||||||
from util.ConfigurationManager import ConfigurationManager
|
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
|
WIDTH = 10 # standard tetris well width, should not be changed
|
||||||
HEIGHT = 20 # standard tetris well height, should not be changed
|
HEIGHT = 20 # standard tetris well height, should not be changed
|
||||||
|
|||||||
24
main.py
24
main.py
@@ -40,14 +40,9 @@ def main():
|
|||||||
pygame.display.set_caption(win_title)
|
pygame.display.set_caption(win_title)
|
||||||
pygame.display.set_icon(loaded_icon)
|
pygame.display.set_icon(loaded_icon)
|
||||||
|
|
||||||
pieces = []
|
current_piece = PieceGenerator.get_piece((300, 100))
|
||||||
|
pieces = [current_piece]
|
||||||
well = Well((280, 80))
|
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
|
is_running = True
|
||||||
while is_running:
|
while is_running:
|
||||||
@@ -58,16 +53,19 @@ def main():
|
|||||||
is_running = False
|
is_running = False
|
||||||
if event.type == pygame.KEYDOWN:
|
if event.type == pygame.KEYDOWN:
|
||||||
if event.key == pygame.K_SPACE:
|
if event.key == pygame.K_SPACE:
|
||||||
[piece.rotate() for piece in pieces]
|
current_piece.rotate()
|
||||||
if event.key == pygame.K_LEFT:
|
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:
|
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:
|
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:
|
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])
|
draw(screen, pieces + [well])
|
||||||
|
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ class PieceGenerator:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_piece(cls, position):
|
def get_piece(cls, position):
|
||||||
piece = Piece(cls.__get_piece_shape(), position, cls.__get_piece_color())
|
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
|
return piece
|
||||||
|
|
||||||
def __get_piece_shape():
|
def __get_piece_shape():
|
||||||
|
|||||||
Reference in New Issue
Block a user