Comments (1)
import pygame
import sys
pygame.init()
Configurar la pantalla
screen = pygame.display.set_mode((800, 600))
pygame.display.set_caption('Juego de IoT en Colombia')
Colores
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
Fuentes
font = pygame.font.Font(None, 36)
Preguntas y respuestas
questions = [
("¿Qué es el IoT?", "Internet de las Cosas"),
("Ejemplo de IoT en la agricultura en Colombia:", "Sensores de suelo"),
("Uso de IoT en la salud en Colombia:", "Monitoreo de pacientes")
]
current_question = 0
user_answer = ''
correct_answers = 0
def draw_text(text, font, color, surface, x, y):
textobj = font.render(text, 1, color)
textrect = textobj.get_rect()
textrect.topleft = (x, y)
surface.blit(textobj, textrect)
Bucle principal del juego
while True:
screen.fill(WHITE)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
# Verificar respuesta
if user_answer.lower() == questions[current_question][1].lower():
correct_answers += 1
current_question += 1
user_answer = ''
if current_question >= len(questions):
current_question = 0
elif event.key == pygame.K_BACKSPACE:
user_answer = user_answer[:-1]
else:
user_answer += event.unicode
if current_question < len(questions):
draw_text(questions[current_question][0], font, BLACK, screen, 20, 100)
draw_text(user_answer, font, BLACK, screen, 20, 200)
else:
draw_text(f'Juego terminado! Respuestas correctas: {correct_answers}', font, BLACK, screen, 20, 100)
pygame.display.update()
from pygame.
Related Issues (20)
- Test failures against NumPy 2.0.0rc2 HOT 9
- Improve Pygame Installation Instructions
- Improve Pygame Installation Instructions
- Flicker Screen
- Mouse cannot focus on vscode when breakpoint on Ubuntu when mouse pressed HOT 1
- Juego autista
- pygame not responding HOT 2
- python setup.py build works but not python -m build --wheel HOT 2
- click on pygame windows result in not responding and crash
- AttributeError: partially initialized module 'pygame' has no attribute 'init' (most likely due to a circular import)
- game HOT 5
- Chess
- gmae
- game
- learn
- Add built-in button / map & character designer
- game
- test_queue fail on latest version (2.6.0) HOT 2
- 2.6.0 pygame installation failure on Ubuntu! HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pygame.