Skip to content

gae #5

Description

@simkimbin

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions