
Ayuda... No puedo cargar eventos de Pygame
Publicado por Bitu (8 intervenciones) el 19/07/2014 19:31:55
Compa~neros... estoy trabajando en un bucle y quiero que cada vez que oprima una tecla la matriz cambie... para ello uso eventos de pygame... y aunque importe el modulo y lo inicialize... no me funciona los eventos... alguna sugerencia???
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
#-*-coding:utf-8-*-
import pygame
espacio=[]
reloj=pygame.time.Clock()
def matriz():
"""
Crea el tablero del juego y Determina su tamano
"""
for i in range(10):
espacio.append(["0"]*11)
return espacio
def mostrar(espacio):
"""
Permite imprimir la matriz de forma clara, sin verse como una lista de listas
"""
for j in espacio:
print " ".join(j) #concatenamos en un solo string todos los elementos de la lista
def hero(tecla):
if tecla=="d":
for x in range(10):
espacio[x][5]="1"
elif tecla=="a":
for x in range(10):
espacio[x][4]="1"
elif tecla=="w":
for x in range(10):
if x==4:
for j in range(11):
espacio[x][j]="1"
elif tecla=="s":
for x in range(10):
if x==5:
for j in range(11):
espacio[x][j]="1"
def cls():
print "\n" * 100
tecla="c"
salir=False
matriz()
pygame.init()
while salir!=True:
cls()
for event in pygame.event.get():
"""
NO SE CARGAN ESTOS EVENTOS...
"""
if event==pygame.KEYDOWN:
salir=True
print "Porfin"
if event.key==pygame.K_DOWN:
tecla="s"
break
if event.key==pygame.K_UP:
tecla="w"
break
if event.key==pygame.K_RIGHT:
tecla="d"
break
if event.key==pygame.K_LEFT:
tecla="a"
break
print tecla
print mostrar(espacio)
reloj.tick(1)
Valora esta pregunta


0