Constantes
WIDTH, HEIGHT = 800, 600
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
FONT = pygame.font.Font(None, 36)
Configuración de la pantalla
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption(“Juego Educativo”)
Función para mostrar texto
def draw_text(text, font, color, surface, x, y):
textobj = font.render(text, True, color)
textrect = textobj.get_rect()
textrect.topleft = (x, y)
surface.blit(textobj, textrect)
Pantalla de inicio
def show_start_screen():
screen.fill(WHITE)
draw_text(‘Juego Educativo’, FONT, BLACK, screen, 20, 20)
draw_text(‘Presiona cualquier tecla para empezar’, FONT, BLACK, screen, 20, 100)
pygame.display.flip()
waiting = True
while waiting:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYUP:
waiting = False
Pantalla de selección de retos
def show_challenge_selection():
screen.fill(WHITE)
draw_text(‘Selecciona un reto:’, FONT, BLACK, screen, 20, 20)
draw_text(‘1. Leer y responder’, FONT, BLACK, screen, 20, 100)
draw_text(‘2. Concurso de fotos’, FONT, BLACK, screen, 20, 150)
draw_text(‘3. Música clásica’, FONT, BLACK, screen, 20, 200)
pygame.display.flip()
selecting = True
while selecting:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYUP:
if event.key == pygame.K_1:
return 'leer'
elif event.key == pygame.K_2:
return 'fotos'
elif event.key == pygame.K_3:
return 'musica'
Pantalla de retos de lectura
def show_reading_challenge():
screen.fill(WHITE)
draw_text(‘Reto de Lectura’, FONT, BLACK, screen, 20, 20)
draw_text(‘Pregunta: ¿Quién descubrió América?’, FONT, BLACK, screen, 20, 100)
draw_text(‘A. Cristóbal Colón’, FONT, BLACK, screen, 20, 150)
draw_text(‘B. Marco Polo’, FONT, BLACK, screen, 20, 200)
draw_text(‘Presiona A o B para responder’, FONT, BLACK, screen, 20, 250)
pygame.display.flip()
answering = True
while answering:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYUP:
if event.key == pygame.K_a:
return True
elif event.key == pygame.K_b:
return False
Pantalla de logros
def show_achievements():
screen.fill(WHITE)
draw_text(‘Logros’, FONT, BLACK, screen, 20, 20)
draw_text(‘¡Has completado un reto!’, FONT, BLACK, screen, 20, 100)
pygame.display.flip()
pygame.time.wait(2000)
Función principal del juego
def main():
while True:
show_start_screen()
challenge = show_challenge_selection()
if challenge == 'leer':
correct = show_reading_challenge()
if correct:
show_achievements()
elif challenge == 'fotos':
# Aquí implementarías la lógica del concurso de fotos
pass
elif challenge == 'musica':
# Aquí implementarías la lógica del reto de música clásica
pass
if name == ‘main’:
main()
pygame.quit()
type or paste code here