Created
August 12, 2021 12:06
-
-
Save thaisviana/5071de16d459e1647874b6ad88121299 to your computer and use it in GitHub Desktop.
Quadradinho
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
from random import randint | |
from CONSTANTS import largura_tela, altura_tela, q_largura, q_altura | |
class Quadradinho(): | |
def __init__(self): | |
self.largura = q_largura | |
self.altura = q_altura | |
self.x = randint(0, largura_tela-self.largura) | |
self.y = randint(0, altura_tela-self.altura) | |
self.area = pygame.Rect(self.x, self.y, self.largura, self.altura) | |
self.cor = (randint(20, 255), randint(20, 255), randint(20, 255)) | |
def desenha(self, tela): | |
pygame.draw.rect(tela, self.cor, self.area) | |
@staticmethod | |
def cria_n_quadradinhos(n): | |
lista =[] | |
for i in range(n): | |
quadradinho = Quadradinho() | |
lista.append(quadradinho) | |
return lista |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment