elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Entrar al Canal Oficial Telegram de elhacker.net


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  [Python] Matrix.py
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Python] Matrix.py  (Leído 2,124 veces)
Erik#


Desconectado Desconectado

Mensajes: 1.138


Gundam


Ver Perfil
[Python] Matrix.py
« en: 12 Febrero 2009, 21:13 pm »

Bueno, me gusto este code, fijaos:

Código
  1. import random
  2. import sys
  3. import pygame
  4. from pygame.locals import *
  5.  
  6. def genera_matrix(posx,posy):
  7.    font = pygame.font.Font(None,20)
  8.    cadena = "abcdefghijklmnopkrstuvwxyz1234567890!#$%&/()=?*[]_:;"
  9.    posicion = []
  10.    while 1:
  11.        pygame.event.pump()
  12.        keyinput = pygame.key.get_pressed()
  13.        if keyinput[K_ESCAPE] or pygame.event.peek(QUIT):
  14.            sys.exit(2)
  15.        if posx not in posicion:
  16.            car = random.randrange(len(cadena))
  17.            green = random.randrange(50,75)
  18.            text = font.render(cadena[car],1,(32,green,32))
  19.            screen.blit(text,(posx,posy))
  20.            if (posy >= 0 and posy <= SCREEN_HEIGHT):
  21.                posy = posy + 12
  22.  
  23.            if posy >= SCREEN_HEIGHT:
  24.                posicion = posicion + [posx]
  25.                posx = random.randrange(SCREEN_WIDTH)
  26.                posy = random.randrange(SCREEN_HEIGHT)
  27.            screen.blit(text,(posx,posy))
  28.            pygame.display.flip()
  29.            pygame.time.wait(100)
  30.        else:
  31.            posx = random.randrange(SCREEN_WIDTH)
  32.            posy = random.randrange(SCREEN_HEIGHT)
  33.  
  34. def genera_binario():
  35.    font = pygame.font.Font(None,16)
  36.    posx_ini = 0
  37.    posy_ini = 0
  38.  
  39.    posx_fin = SCREEN_WIDTH
  40.    posy_fin = SCREEN_HEIGHT
  41.    cadena_binario = "01"
  42.  
  43.    while 1:
  44.        car = random.randrange(len(cadena_binario))
  45.        green = random.randrange(0,39)
  46.        text = font.render(cadena_binario[car],1,(12,green,12))
  47.        screen.blit(text,(posx_ini,posy_ini))
  48.  
  49.        if (posx_ini >= 0 and posx_ini <= posx_fin):
  50.            posx_ini = posx_ini + 10
  51.  
  52.        else:
  53.            posx_ini = 0
  54.            posy_ini = posy_ini + 10
  55.        if posx_ini == posx_fin and posy_ini == posy_fin:
  56.            posx = random.randrange(SCREEN_WIDTH)
  57.            posy = 0
  58.            genera_matrix(posx,posy)
  59.        pygame.display.flip()
  60.  
  61. def main():
  62.    if not pygame.font:
  63.        print "Desabilitado Tipo de Letras"
  64.  
  65.    else:
  66.        pygame.font.init()
  67.  
  68.    global SCREEN_WIDTH, SCREEN_HEIGHT, screen
  69.    SCREEN_WIDTH  = 640
  70.    SCREEN_HEIGHT = 480
  71.    pygame.init()
  72.    screen = pygame.display.set_mode((SCREEN_WIDTH,SCREEN_HEIGHT))
  73.    pygame.display.set_caption("PyMatrix")
  74.    genera_binario()
  75.  
  76. if __name__=="__main__":
  77.    main()
  78.  


« Última modificación: 28 Febrero 2009, 11:39 am por sirdarckcat » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Porque no me sirve matrix :el path of neo?
Juegos y Consolas
Pedro122h 1 3,518 Último mensaje 8 Julio 2021, 18:28 pm
por crazykenny
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines