i messed up and wanted to make it but i didn’t make it work

import sys, pygame, random

pygame.init()

WIDTH, HEIGHT = 800, 600

GRID_SIZE = 25

WHITE = (255, 255, 255)

BLACK = (0, 0, 0)

COLORS = [(255,0,0), (0,255,0), (0,0,255)]

SHAPES = [

   [[‘…..’,’…..’,’…..’,’OOOO.’,’…..’],

    [‘..O..’,’..O..’,’..O..’,’..O..’,’…..’]],

   [[‘…..’,’..O..’,’.OOO.’,’…..’,’…..’]]

]

class Tetromino:

   def __init__(self, x, y, shape):

       self.x = x

       self.y = y

       self.shape = shape

       self.color = random.choice(COLORS)

       self.rotation = 0

       class Tetris:

        def __init__(self, width, height):

            self.width = width

        self.height = height

        self.grid = [[0]*width for _ in range(height)]

        self.current_piece = self.new_piece()

        self.score = 0

        self.game_over = False

   def new_piece(self):

       return Tetromino(self.width//2, 0, random.choice(SHAPES))

   def main():

    screen = pygame.display.set_mode((WIDTH, HEIGHT))

   clock = pygame.time.Clock()

   game = Tetris(WIDTH//GRID_SIZE, HEIGHT//GRID_SIZE)

   while True:

       screen.fill(BLACK)

       for event in pygame.event.get():

           if event.type == pygame.QUIT:

               pygame.quit(); sys.exit()

       game.update()

       game.draw(screen)

       pygame.display.flip()

       clock.tick(60)

main()

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top