Untitled
unknown
plain_text
10 months ago
1.0 kB
12
Indexable
import pygame
pygame.init()
#colors
background_color = (100, 50, 255)
pink = (255, 0, 150)
black = (0, 0, 0)
main_window = pygame.display.set_mode((500,500))
clock = pygame.time.Clock()
class TextArea():
def __init__(self, x, y, width, height, color):
self.rect = pygame.Rect(x, y, width, height)
self.fill_color = color
def set_text(self, text, fsize = 20, text_color =black):
self.text = text
self.image = pygame.font.Font(None, fsize).render(text, True, text_color)
def draw(self):
pygame.draw.rect(main_window, self.fill_color, self.rect)
main_window.blit(self.image, (self.rect.x, self.rect.y))
question = TextArea(170, 50, 240, 110, pink)
answer = TextArea(170, 300, 240, 110 , pink)
question.set_text("Питання", 50)
answer.set_text("Відповідь",50)
while True:
main_window.fill(background_color)
question.draw()
answer.draw()
clock.tick(40)
pygame.display.update()Editor is loading...
Leave a Comment