Código de Python - Texto en movimiento en una ventana con pygame

Requerimientos

pygame
Python 2 o Python 3

Versión 1
estrellaestrellaestrellaestrellaestrella(1)

Publicado el 29 de Julio del 2016gráfica de visualizaciones de la versión: Versión 1
6.505 visualizaciones desde el 29 de Julio del 2016
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella


Forma parte de Animation
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import pygame, sys
from pygame.locals import *
pygame.init()
 
YSIZE = 40
XSIZE = 150
 
TEXT = "Hello World! "
FONTSIZE = 32
 
LEFT = False
RIGHT = True
 
DIR = RIGHT
 
TIMETICK = 180
TICK = USEREVENT + 2
 
TEXTBOX = pygame.Rect(10,10,XSIZE,YSIZE)
 
pygame.time.set_timer(TICK, TIMETICK)
 
window = pygame.display.set_mode((XSIZE, YSIZE))
pygame.display.set_caption("Animation")
 
font = pygame.font.SysFont(None, FONTSIZE)
screen = pygame.display.get_surface()
 
def rotate():
    index = DIR and -1 or 1
    global TEXT
    TEXT = TEXT[index:]+TEXT[:index]
 
def click(position):
    if TEXTBOX.collidepoint(position):
        global DIR
        DIR = not DIR
 
def draw():
    surface = font.render(TEXT, True, (255,255,255), (0,0,0))
    global TEXTBOX
    TEXTBOX = screen.blit(surface, TEXTBOX)
 
def input(event):
    if event.type == QUIT:
        sys.exit(0)
    elif event.type == MOUSEBUTTONDOWN:
        click(event.pos)
    elif event.type == TICK:
        draw()
        rotate()
 
while True:
    input(pygame.event.wait())
    pygame.display.flip()



Comentarios sobre la versión: Versión 1 (1)

LEYE
27 de Julio del 2020
estrellaestrellaestrellaestrellaestrella
ESTA MUY BUENO
Responder

Comentar la versión: Versión 1

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s3613