After you get use to python. Learn Classes. 99% of everything in python is an object.
Here an example.
Here an example.
import pygame pygame.init() def create_button(font, text, text_color, color, rect): # Use the pygame Rect. rect = pygame.Rect(rect) surface = pygame.Surface(rect.size) surface.fill(color) center = rect.centerx - rect.x, rect.centery - rect.y text_image = font.render(text, 1, text_color) text_rect = text_image.get_rect(center=center) surface.blit(text_image, text_rect) return surface, rect def main(): pygame.display.set_caption("Button Example") display = pygame.display.set_mode((800, 600)) clock = pygame.time.Clock() fps = 60 font20 = pygame.font.Font(None, 20) font50 = pygame.font.Font(None, 50) # Button will be a tuple. (image, rect) button = create_button(font20, "MyButton", pygame.Color("grey50"), pygame.Color("grey70"), (50, 50, 150, 30)) # Create your text. Then render it. This is a tuple. (text_image, position) clicky_click = font50.render("Clicky Click", 1, pygame.Color("white")), (400, 100) running = True while running: for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: if button[1].collidepoint(event.pos): print("You push my buttons") elif event.type == pygame.QUIT: running = False display.fill(pygame.Color('black') display.blit(button[0], button[1]) display.blit(clicky_click[0], clicky_click[1]) pygame.display.update() # Idle/Sleep clock.tick(fps) main()
99 percent of computer problems exists between chair and keyboard.