This is using all modules as you have initialized them here on line 7
You can uses system fonts, but from my experience its not a good idea when packaging a game. For example some people may have certain fonts on their system while others not, causing an error for them. Its much more solid if you just send a font along with your program.
PS you dont need all those flips everywhere.
pygame.init()So in your code you are already initializing mixer and ttf
You can uses system fonts, but from my experience its not a good idea when packaging a game. For example some people may have certain fonts on their system while others not, causing an error for them. Its much more solid if you just send a font along with your program.
PS you dont need all those flips everywhere.
import pygame import random import sys go = True pygame.init() screen = pygame.display.set_mode([500,500]) pygame.display.set_caption('Pygame test') font = pygame.font.SysFont(None, 60) def writetext(outputtext,colour): text = font.render(outputtext, True, colour) size_rect = text.get_rect(center = (500/2, 54)) screen.blit(text,size_rect) while go: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if event.type == pygame.MOUSEBUTTONDOWN: x = random.randint(1,2) if x == 1: writetext("Yes!", (255,255,255)) elif x == 2: writetext("No!", (255,255,255)) pygame.display.update()
Recommended Tutorials: