feat: add rotation logic for piece
This commit is contained in:
24
main.py
24
main.py
@@ -24,6 +24,8 @@ def main():
|
||||
win_icon = ConfigurationManager.configuration["window"]["icon"]
|
||||
win_title = ConfigurationManager.configuration["window"]["title"]
|
||||
fps = ConfigurationManager.configuration["engine"]["fps"]
|
||||
base_one_color = ConfigurationManager.configuration["color"]["base-1"]
|
||||
tile_size = ConfigurationManager.configuration["engine"]["tile-size"]
|
||||
|
||||
screen = pygame.display.set_mode((win_width, win_height))
|
||||
clock = pygame.time.Clock()
|
||||
@@ -32,7 +34,6 @@ def main():
|
||||
pygame.display.set_caption(win_title)
|
||||
pygame.display.set_icon(loaded_icon)
|
||||
|
||||
base_one_color = ConfigurationManager.configuration["color"]["base-1"]
|
||||
i_piece = Piece(Piece.I_SHAPE, (100, 100), base_one_color)
|
||||
|
||||
is_running = True
|
||||
@@ -42,16 +43,17 @@ def main():
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
is_running = False
|
||||
|
||||
keys = pygame.key.get_pressed()
|
||||
if keys[pygame.K_LEFT]:
|
||||
i_piece.move((-5, 0))
|
||||
if keys[pygame.K_RIGHT]:
|
||||
i_piece.move((5, 0))
|
||||
if keys[pygame.K_UP]:
|
||||
i_piece.move((0, -5))
|
||||
if keys[pygame.K_DOWN]:
|
||||
i_piece.move((0, 5))
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_SPACE:
|
||||
i_piece.rotate()
|
||||
if event.key == pygame.K_LEFT:
|
||||
i_piece.move((-tile_size, 0))
|
||||
if event.key == pygame.K_RIGHT:
|
||||
i_piece.move((tile_size, 0))
|
||||
if event.key == pygame.K_UP:
|
||||
i_piece.move((0, -tile_size))
|
||||
if event.key == pygame.K_DOWN:
|
||||
i_piece.move((0, tile_size))
|
||||
|
||||
draw(screen, [i_piece])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user