Download - Programación con Pygame I
![Page 1: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/1.jpg)
PYGAME (I)Conceptos Básicos
![Page 2: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/2.jpg)
¿Qué es Pygame?
![Page 3: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/3.jpg)
¿Qué es Pygame?
Una librería que permite trabajar con imágenes y sonido...
![Page 4: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/4.jpg)
¿Qué es Pygame?
Una librería que permite trabajar con imágenes y sonido...
¡Abierta y gratuita!
![Page 5: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/5.jpg)
¿Qué es Pygame?
Una librería que permite trabajar con imágenes y sonido...
¡Abierta y gratuita!
¡Animadas!
![Page 6: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/6.jpg)
¿Qué es Pygame?
Una librería que permite trabajar con imágenes y sonido...
¡Abierta y gratuita!
¡Animadas!
... que gestiona su interacción...
![Page 7: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/7.jpg)
¿Qué es Pygame?
Una librería que permite trabajar con imágenes y sonido...
¡Abierta y gratuita!
¡Animadas!
... que gestiona su interacción...Sprites
![Page 8: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/8.jpg)
¿Qué es Pygame?
Una librería que permite trabajar con imágenes y sonido...
¡Abierta y gratuita!
¡Animadas!
... que gestiona su interacción...Sprites
... y que controla el Hardware.
![Page 9: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/9.jpg)
¿Qué es Pygame?
Una librería que permite trabajar con imágenes y sonido...
¡Abierta y gratuita!
¡Animadas!
... que gestiona su interacción...Sprites
... y que controla el Hardware.
Buclede
Eventos
![Page 10: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/10.jpg)
Esquema General
![Page 11: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/11.jpg)
Esquema General
Importación
![Page 12: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/12.jpg)
Esquema General
Importación
Inicialización
![Page 13: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/13.jpg)
Esquema General
Importación
Inicialización
Ejecución
![Page 14: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/14.jpg)
Importación
![Page 15: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/15.jpg)
Importación
import pygamefrom pygame.locals import *import sys
![Page 16: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/16.jpg)
Importación
import pygamefrom pygame.locals import *import sys
El módulo sys es importante para trabajar correctamente con el sistema operativo.
En particularsys.exit( )
![Page 17: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/17.jpg)
Importación
import pygamefrom pygame.locals import *import sys
El módulo sys es importante para trabajar correctamente con el sistema operativo.
En particularsys.exit( )
Contiene variables y constantes muy útiles
![Page 18: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/18.jpg)
Inicialización
![Page 19: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/19.jpg)
Inicialización
pygame.init( )
![Page 20: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/20.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
display.set_mode( ) crea la superficie de visualización.
![Page 21: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/21.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
display.set_mode( ) crea la superficie de visualización.
Tamaño de la superficie
![Page 22: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/22.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
display.set_mode( ) crea la superficie de visualización.
Tamaño de la superficie
Opciones
![Page 23: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/23.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
display.set_mode( ) crea la superficie de visualización.
Tamaño de la superficie
Opciones
Profundidad de color
![Page 24: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/24.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
![Page 25: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/25.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
visor contiene un objeto Surface que puede ser una ventana o la pantalla completa.
![Page 26: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/26.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
visor contiene un objeto Surface que puede ser una ventana o la pantalla completa.
¡Aquí es donde se mostrarán las
animaciones!
![Page 27: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/27.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
Opciones
![Page 28: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/28.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
FULLSCREEN Pantalla completa.
Opciones
![Page 29: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/29.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
FULLSCREEN Pantalla completa.
Opciones
RESIZABLE Tamaño variable.
![Page 30: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/30.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
FULLSCREEN Pantalla completa.
Opciones
RESIZABLE Tamaño variable.
NOFRAME Sin bordes ni título.
![Page 31: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/31.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
FULLSCREEN Pantalla completa.
Opciones
RESIZABLE Tamaño variable.
NOFRAME Sin bordes ni título.
OPENGL Para 3D.
![Page 32: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/32.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
FULLSCREEN Pantalla completa.
Opciones
RESIZABLE Tamaño variable.
NOFRAME Sin bordes ni título.
OPENGL Para 3D.
DOUBLEBUF Doble bufer.
![Page 33: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/33.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
FULLSCREEN Pantalla completa.
Opciones
RESIZABLE Tamaño variable.
NOFRAME Sin bordes ni título.
OPENGL Para 3D.
DOUBLEBUF Doble bufer.
HWSURFACE Acelerada por Hardware.
![Page 34: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/34.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
FULLSCREEN Pantalla completa.
Opciones
RESIZABLE Tamaño variable.
NOFRAME Sin bordes ni título.
OPENGL Para 3D.
DOUBLEBUF Doble bufer.
HWSURFACE Acelerada por Hardware.
Puedo poner varias con | de separador
![Page 35: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/35.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
Profundidad de color (en bits)
![Page 36: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/36.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
Profundidad de color (en bits)
8 256 colores.
![Page 37: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/37.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
Profundidad de color (en bits)
8 256 colores. 15 32 768 colores con transparencia.
![Page 38: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/38.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
Profundidad de color (en bits)
8 256 colores. 15 32 768 colores con transparencia.
16 65 536 colores.
![Page 39: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/39.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
Profundidad de color (en bits)
8 256 colores. 15 32 768 colores con transparencia.
16 65 536 colores. 24 16.7 millones de colores.
![Page 40: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/40.jpg)
Inicialización
pygame.init( )visor = pygame.display.set_mode((640, 480), 0, 32)
Profundidad de color (en bits)
8 256 colores. 15 32 768 colores con transparencia.
16 65 536 colores. 24 16.7 millones de colores.
32 16.7 millones de colores con transparencia.
![Page 41: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/41.jpg)
Ejecución
![Page 42: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/42.jpg)
Ejecución
Mostrar imágenes y sonido
![Page 43: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/43.jpg)
Ejecución
Mostrar imágenes y sonido
Responder a las acciones del jugador
![Page 44: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/44.jpg)
Ejecución
Mostrar imágenes y sonido
Responder a las acciones del jugador
Detectar las incidencias en el juego
![Page 45: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/45.jpg)
Ejecución
Mostrar imágenes y sonido
Responder a las acciones del jugador
Detectar las incidencias en el juego
Y debo hacerlo una y otra vez, continuamente, durante todo el juego.
![Page 46: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/46.jpg)
Ejecución
Mostrar imágenes y sonido
Responder a las acciones del jugador
Detectar las incidencias en el juego
Y debo hacerlo una y otra vez, continuamente, durante todo el juego.
FPSFotogramas por Segundo
Buclede
Eventos
![Page 47: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/47.jpg)
![Page 48: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/48.jpg)
Bucle de Eventos
Todo lo que ocurre durante el juego debe estar aquí.
![Page 49: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/49.jpg)
Bucle de Eventoswhile True: ... for event in pygame.event.get( ): ... if event.type == QUIT: pygame.quit( ) sys.exit( )
Todo lo que ocurre durante el juego debe estar aquí.
![Page 50: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/50.jpg)
Bucle de Eventoswhile True: ... for event in pygame.event.get( ): ... if event.type == QUIT: pygame.quit( ) sys.exit( )
Todo lo que ocurre durante el juego debe estar aquí.
Mirar la lista de eventos
![Page 51: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/51.jpg)
Bucle de Eventoswhile True: ... for event in pygame.event.get( ): ... if event.type == QUIT: pygame.quit( ) sys.exit( )
Todo lo que ocurre durante el juego debe estar aquí.
Mirar la lista de eventos
Responder al tipo de evento
![Page 52: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/52.jpg)
Bucle de Eventoswhile True: ... for event in pygame.event.get( ): ... if event.type == QUIT: pygame.quit( ) sys.exit( )
Todo lo que ocurre durante el juego debe estar aquí.
Mirar la lista de eventos
Responder al tipo de evento from pygame.locals import *
![Page 53: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/53.jpg)
while True: ... for event in pygame.event.get( ): ... if event.type == QUIT: pygame.quit( ) sys.exit( )
![Page 54: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/54.jpg)
while True: ... for event in pygame.event.get( ): ... if event.type == QUIT: pygame.quit( ) sys.exit( )
Haz sin parar: ... Mira cada evento pendiente: ... Si el tipo de evento es salir: sal de pygame sal del programa
Observa lo que se está haciendo...
![Page 55: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/55.jpg)
while True: ... for event in pygame.event.get( ): ... if event.type == QUIT: pygame.quit( ) sys.exit( )
Haz sin parar: ... Mira cada evento pendiente: ... Si el tipo de evento es salir: sal de pygame sal del programa
Observa lo que se está haciendo...
Aquí se pondrán el resto de los
procesos...
![Page 56: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/56.jpg)
while True: ... for event in pygame.event.get( ): ... if event.type == QUIT: pygame.quit( ) sys.exit( )
Haz sin parar: ... Mira cada evento pendiente: ... Si el tipo de evento es salir: sal de pygame sal del programa
Observa lo que se está haciendo...
Aquí se pondrán el resto de los
procesos...
... y eventos.
![Page 57: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/57.jpg)
![Page 58: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/58.jpg)
Dibujado en Pantalla
![Page 59: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/59.jpg)
Dibujado en PantallaPara evitar artefactos se dibuja offscreen y luego se vuelca todo en pantalla.
![Page 60: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/60.jpg)
Dibujado en PantallaPara evitar artefactos se dibuja offscreen y luego se vuelca todo en pantalla.
Usando el métodovisor.blit( )
![Page 61: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/61.jpg)
Dibujado en PantallaPara evitar artefactos se dibuja offscreen y luego se vuelca todo en pantalla.
Usando el métodovisor.blit( )
Usando el métodopygame.display.update( )
![Page 62: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/62.jpg)
Dibujado en PantallaPara evitar artefactos se dibuja offscreen y luego se vuelca todo en pantalla.
Usando el métodovisor.blit( )
Usando el métodopygame.display.update( )
FrameFotograma
![Page 63: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/63.jpg)
Dibujado en PantallaPara evitar artefactos se dibuja offscreen y luego se vuelca todo en pantalla.
Usando el métodovisor.blit( )
Usando el métodopygame.display.update( )
FrameFotograma
¡Muchos fotogramas
producen una
animación...
... si son diferentes!
![Page 64: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/64.jpg)
![Page 65: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/65.jpg)
En realidad hay más métodos para dibujar offscreen...
![Page 66: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/66.jpg)
En realidad hay más métodos para dibujar offscreen...
blit( ) para imágenes.
![Page 67: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/67.jpg)
En realidad hay más métodos para dibujar offscreen...
blit( ) para imágenes.
draw.line( ) líneas
![Page 68: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/68.jpg)
En realidad hay más métodos para dibujar offscreen...
blit( ) para imágenes.
draw.line( ) líneas
draw.circle( ) círculos
![Page 69: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/69.jpg)
En realidad hay más métodos para dibujar offscreen...
blit( ) para imágenes.
draw.line( ) líneas
draw.circle( ) círculos
draw.ellipse( ) elipses
![Page 70: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/70.jpg)
En realidad hay más métodos para dibujar offscreen...
blit( ) para imágenes.
draw.line( ) líneas
draw.circle( ) círculos
draw.ellipse( ) elipses
draw.rect( ) rectángulos
![Page 71: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/71.jpg)
En realidad hay más métodos para dibujar offscreen...
blit( ) para imágenes.
draw.line( ) líneas
draw.circle( ) círculos
draw.ellipse( ) elipses...
draw.rect( ) rectángulos
![Page 72: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/72.jpg)
En realidad hay más métodos para dibujar offscreen...
blit( ) para imágenes.
draw.line( ) líneas
draw.circle( ) círculos
draw.ellipse( ) elipses
Consulta la documentación.
...
draw.rect( ) rectángulos
![Page 73: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/73.jpg)
¿Cómo defino Colores y Posiciones?
![Page 74: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/74.jpg)
¿Cómo defino Colores y Posiciones?
Colores con tuplas RGB.
colorVerde = (0,255,0)r g b
![Page 75: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/75.jpg)
¿Cómo defino Colores y Posiciones?
Colores con tuplas RGB.
Posiciones con tuplas 2D.
colorVerde = (0,255,0)
punto = (223,327)
r g b
x y
![Page 76: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/76.jpg)
¿Cómo defino Colores y Posiciones?
Colores con tuplas RGB.
Posiciones con tuplas 2D.
Y zonas con tuplas RECT.
colorVerde = (0,255,0)
punto = (223,327)
zona = (0,0,300,200)
r g b
x y
![Page 77: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/77.jpg)
¿Y cómo dibujar Texto ?
![Page 78: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/78.jpg)
¿Y cómo dibujar Texto ?
Primero, definimos el tipo de letra.
![Page 79: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/79.jpg)
¿Y cómo dibujar Texto ?
Primero, definimos el tipo de letra.
Segundo, generamos el texto.
![Page 80: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/80.jpg)
¿Y cómo dibujar Texto ?
Primero, definimos el tipo de letra.
Segundo, generamos el texto.
Y tercero, lo dibujamos offscreen.
![Page 81: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/81.jpg)
¿Y cómo dibujar Texto ?
Primero, definimos el tipo de letra.
Segundo, generamos el texto.
Y tercero, lo dibujamos offscreen.
tipoLetra = pygame.font.SysFont(‘arial’, 48)
![Page 82: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/82.jpg)
¿Y cómo dibujar Texto ?
Primero, definimos el tipo de letra.
Segundo, generamos el texto.
Y tercero, lo dibujamos offscreen.
tipoLetra = pygame.font.SysFont(‘arial’, 48)
texto = tipoLetra.render('Hola', True, color1, color2)
![Page 83: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/83.jpg)
¿Y cómo dibujar Texto ?
Primero, definimos el tipo de letra.
Segundo, generamos el texto.
Y tercero, lo dibujamos offscreen.
tipoLetra = pygame.font.SysFont(‘arial’, 48)
texto = tipoLetra.render('Hola', True, color1, color2)
de texto de fondoSuavizar
![Page 84: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/84.jpg)
¿Y cómo dibujar Texto ?
Primero, definimos el tipo de letra.
Segundo, generamos el texto.
Y tercero, lo dibujamos offscreen.
tipoLetra = pygame.font.SysFont(‘arial’, 48)
texto = tipoLetra.render('Hola', True, color1, color2)
visor.blit(texto, textRect)
de texto de fondoSuavizar
![Page 85: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/85.jpg)
¿Y cómo dibujar Texto ?
Primero, definimos el tipo de letra.
Segundo, generamos el texto.
Y tercero, lo dibujamos offscreen.
tipoLetra = pygame.font.SysFont(‘arial’, 48)
texto = tipoLetra.render('Hola', True, color1, color2)
visor.blit(texto, textRect)
de texto de fondoSuavizar
lugar
![Page 86: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/86.jpg)
![Page 87: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/87.jpg)
¡Todo es un objeto!
![Page 88: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/88.jpg)
¡Todo es un objeto!Siempre podemos acceder a sus propiedades o usar sus métodos.
![Page 89: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/89.jpg)
¡Todo es un objeto!Siempre podemos acceder a sus propiedades o usar sus métodos.
xCentro = visor.get_rect( ).centerx
![Page 90: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/90.jpg)
¡Todo es un objeto!Siempre podemos acceder a sus propiedades o usar sus métodos.
xCentro = visor.get_rect( ).centerx
visor.fill((0,0,0))
![Page 91: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/91.jpg)
¡Todo es un objeto!Siempre podemos acceder a sus propiedades o usar sus métodos.
xCentro = visor.get_rect( ).centerx
visor.fill((0,0,0))
Consulta la Documentación.
![Page 92: Programación con Pygame I](https://reader035.vdocuments.mx/reader035/viewer/2022081419/557bb859d8b42ace668b49c8/html5/thumbnails/92.jpg)
¿Preguntas?