-
Notifications
You must be signed in to change notification settings - Fork 93
Open
Description
import pygame
import random
Initialize Pygame
pygame.init()
Constants
WIDTH, HEIGHT = 600, 600
TILE_SIZE = 100
BOARD_SIZE = 6
COLORS = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 0), (255, 165, 0)]
Create the display
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Match Three Game")
Create the board
board = [[random.choice(COLORS) for _ in range(BOARD_SIZE)] for _ in range(BOARD_SIZE)]
def draw_board():
for y in range(BOARD_SIZE):
for x in range(BOARD_SIZE):
pygame.draw.rect(screen, board[y][x], (x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE))
pygame.draw.rect(screen, (0, 0, 0), (x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE), 2)
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
screen.fill((255, 255, 255))
draw_board()
pygame.display.flip()
pygame.quit()
Metadata
Metadata
Assignees
Labels
No labels