Skip to content

Commit

Permalink
feat: Added support for colors in pygame gui
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduard-Prokhorikhin committed Apr 23, 2024
1 parent 1eae354 commit 32d03ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
board = Tetris()
manager = TetrisGameManager(board)

manager.startGame()
manager.startGame()
8 changes: 4 additions & 4 deletions src/game/TetrisGameManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
import sys

from src.game.tetris import Action, Tetris
from src.game.block import COLORS

baseScore = 100

# pygame visuals setup
BLOCK_SIZE = 30
BLOCK_SIZE = 40
WIDTH = 10
HEIGHT = 23
START_HEIGHT = 3
Expand All @@ -19,7 +20,6 @@
# Colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
BLUE = (0, 0, 255)

class TetrisGameManager:
currentPiece = None
Expand Down Expand Up @@ -88,8 +88,8 @@ def draw_board(self, gameState: Tetris):
temp_board = temp.board[START_HEIGHT:]
for y in range(HEIGHT-START_HEIGHT):
for x in range(WIDTH):
if temp_board[y][x] == 1:
pygame.draw.rect(self.screen, BLUE, (x * BLOCK_SIZE, y * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE))
if temp_board[y][x] != 0:
pygame.draw.rect(self.screen, COLORS[temp_board[y][x]-1], (x * BLOCK_SIZE, y * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE))
pygame.draw.rect(self.screen, WHITE, (x * BLOCK_SIZE, y * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE), 1)


Expand Down

0 comments on commit 32d03ba

Please sign in to comment.