[linuxlsc] Re: Juego...

  • From: "Pablo Olmos de Aguilera" <pablo.olmosdeaguilera@xxxxxxxxx>
  • To: linuxlsc@xxxxxxxxxxxxx
  • Date: Wed, 28 Nov 2007 12:50:06 -0300

Se hace necesario un CVS o SVN =P....

Saludos!

El día 28/11/07, Mikel David Carozzi Sanchez <cadrogui@xxxxxxxxx> escribió:
>
> ya po cabros motivence con el aprendizaje del juego, aca les mando un
> code introductorio que enseña lo basico del tema de juegos con pygame:
>
> #!/usr/bin/python
> # -*- coding: LATIN-1 -*-
>
> # CODIGO ESCRITO POR MIKELCAROZZI.
>
> import pygame, sys # IMPORTO LA LIBRERIA PYGAME Y SYS (POR AHORA NO
> OCUPADA)
> from pygame.locals import * # IMPORTO TODO DE LA LIBRERIA PYGAME
>
> pygame.init() # INICIO PYGAME
> screen = pygame.display.set_mode((640,480)) #ESTABLEZCO EL TAMAÑO DE
> LA VENTANA
> titulo = pygame.display.set_caption('MOTIVACION CABROS!!!!!!!!!') #
> ESTABLEZCO EL TITULO DE LA VENTANA
>
> imagen = pygame.image.load('bsd.png').convert() # CARGO LA IMAGEN
> screen.blit(imagen, (0,0)) # UBICO LA IMAGEN EN LAS COORDENADAS 0,0
> pygame.display.update() # ACTUALIZO LA PANTALLA (SURFACE)
>
> i, j = 0, 0  #HAGO EL BUCLE Q DETECTA LOS EVENTOS DEL TECLADO
> while True:
>      for event in pygame.event.get():
>          if event.type == QUIT:
>              raise Exception
>          elif event.type == KEYDOWN:
>              if event.key == K_UP:
>                 print "Presionaste ARRIBA"
>                  if j >= 0:
>                      j -= 30
>              elif event.key == K_DOWN:
>                 print "Presionaste ABAJO"
>                  if j <= 640:
>                      j += 30
>              elif event.key == K_LEFT:
>                 print "Presionaste IZQUIERDA"
>                  if i >= 0:
>                      i -= 30
>              elif event.key == K_RIGHT:
>                 print "Presionaste DERECHA"
>                  if i <= 480:
>                      i += 30
>              elif event.key == K_q:
>                  print "has pulsado q, saliendo ADIOS..."
>                 raise SystemExit
>
>      screen.fill(0)
>      screen.blit(imagen, (i,j)) # MUEVO LA IMAGEN EN RELACION A LAS
> COORDENADAS OBTENIDAS DEL BUCLE
>      pygame.display.update()
>
>
> tienen que tener una imagen llamada bsd.png en el mismo directorio
> donde esta el script, esta demas decir que es necesario PYTHON Y PYGAME.
>
> salu2 y espero  que le vayan agregando mas cosas bien explicadas para
> que todos aprendamos.
>
> Mensaje enviado a linuxlsc@xxxxxxxxxxxxx (lista de correo de LinuxLSC -
> Grupo de Usuarios de GNU/Linux de La Serena & Coquimbo, Chile).
>
> <*> Sitio web de la lista de correo:
>     //www.freelists.org/list/linuxlsc
>
> <*> Para cancelar tu suscripción a esta lista, envía un mensaje, colocando
>     como asunto 'unsubscribe' [sin comillas] a:
>     linuxlsc-request@xxxxxxxxxxxxx
>
>

Other related posts: