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)
- حندوقة
- Resizing games is now impossible HOT 2
- Strange behavior of Surface's fill method in negative coordinates
- Strange behavior of Surface's fill method in negative coordinates HOT 5
- transform.scale_by rounding issue HOT 3
- Pygame 2.1.0 fails to install HOT 8
- Can the function of triggering vibration be added? HOT 1
- pygame.keydown doesnt work on unicode HOT 1
- Setting pygame.SRCALPHA influences rotation outcome HOT 1
- Pygame: bad performance because of Neon HOT 1
- problem opening a window in linux mint HOT 7
- Saltaron
- pygame.display.get_surface() invalidates the original surface object from pygame.display.set_mode()
- Add constants to Vectors HOT 1
- Add integer Vectors HOT 1
- pip install pygame HOT 1
- NPC - with lists and responses; but responsive section does not work. HOT 6
- NPC basic in-game movement HOT 5
- FileNotFoundError: HOT 1
- An error occurred while downloading pygame, please help me! HOT 3
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.