Development Journal - Day 11
Development Journal - Day 11
- Allow the player to roll the dice after answering the question
Date: 3/18/2024
Tasks to work on:
- Getting the player to roll the dice after answering the questions
Problem solved: I was able to get the player to roll the dice after answering the questions
correctly.
def display_question():
question = random.choice(list(questions_answers.keys()))
waiting = True
while waiting:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if input_box.collidepoint(event.pos):
active = not active
else:
active = False
color = color_active if active else color_inactive
if event.type == pygame.KEYDOWN:
if active:
if event.key == pygame.K_RETURN:
waiting = False
elif event.key == pygame.K_BACKSPACE:
text = text[:-1]
else:
text += event.unicode
screen.fill((30, 30, 30))
pygame.draw.rect(screen, color, input_box)
font = pygame.font.Font(None, 32)
txt_surface = font.render(text, True, (255, 255, 255))
width = max(200, txt_surface.get_width() + 10)
input_box.w = width
screen.blit(txt_surface, (input_box.x + 5, input_box.y + 5))
pygame.draw.rect(screen, (255, 255, 255), input_box, 2)
pygame.display.flip()
clock.tick(30)
return text.strip()