Untitled

 avatar
unknown
plain_text
a year ago
877 B
14
Indexable
import pygame
import random

pygame.init()

# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GRAY = (128, 128, 128)

class Shape:
    def __init__(self):
        self.x = 5
        self.y = 0
        self.color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
        self.blocks = []

    def move_down(self, grid):
        if self.y + len(self.blocks) == len(grid):
            return False
        for i, row in enumerate(self.blocks):
            for j, val in enumerate(row):
                if val and grid[self.y + i + 1][self.x + j]:
                    return False
        self.y += 1
        return True

    def move_side(self, dx, grid):
        if self.x + len(self.blocks[0]) + dx > len(grid[0]) or self.x + dx < 0:
            return False
        for i, row in enumerate(self.blocks):
            for j, val in enumerate
Editor is loading...
Leave a Comment