Python - PyGame ayuda

 
Vista:
sin imagen de perfil

PyGame ayuda

Publicado por Nicolas (5 intervenciones) el 11/09/2017 05:55:18
Hola, alguien me podria ayudar en como terminar esta pregunta? llegue solo a tener como obtener las coordenadas del click del mouse, no se como seguir para que se muevan
adjunto lo que llevo de codigo:

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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import pygame, ctypes as ct
from pygame.locals import *
 
nRES = (572,323) ; lOK = True ; nPAUSA = 5
nNIVELY_0 = 290 ; nNIVELY_1 = 264 ; nNIVELY_2 = 238
nNIVELY_3 = 212 ; nNIVELY_4 = 186 ; nNIVELY_5 = 160
nNIVELY_6 = 134 ; nNIVELY_7 = 108 ; nNIVELY_8 = 82
nNIVELY_9 = 56
nNIVELX_0 = 35 ; nNIVELX_1 = 70 ; nNIVELX_2 = 107 ; nNIVELX_3 = 142
nNIVELX_4 = 179 ; nNIVELX_5 = 214 ; nNIVELX_6 = 251 ; nNIVELX_7 = 286
nNIVELX_8 = 323 ; nNIVELX_9 = 358 ; nNIVELX_10 = 395 ; nNIVELX_11 = 430
nNIVELX_12 = 467 ; nNIVELX_13 = 502
 
class eBarra(ct.Structure):
    _fields_=[('nX',ct.c_short),
    ('nY',ct.c_short),
    ('nD',ct.c_short),
    ('nI',ct.c_short),
    ('nT',ct.c_short)]
 
class eGarra(ct.Structure):
    _fields_=[('nX',ct.c_short),
    ('nY',ct.c_short),
    ('nD',ct.c_short),
    ('nI',ct.c_short)]
 
class eCarga(ct.Structure):
    _fields_=[('nX',ct.c_short),
    ('nY',ct.c_short),
    ('nD',ct.c_short),
    ('nI',ct.c_short)]
 
def Load_Image(sFile,transp = False):
    try: image = pygame.image.load(sFile)
    except pygame.error,message:
        raise SystemExit,message
    image = image.convert()
    if transp:
        color = image.get_at((0,0))
        image.set_colorkey(color,RLEACCEL)
    return image
 
def PyGame_Init():
    pygame.init()
    pygame.display.set_caption('Pregunta 5 proyecto 1')
    pygame.mouse.set_visible(True)
    return pygame.display.set_mode(nRES)
 
def Fig_Init():
    aImg = []
    aImg.append(Load_Image('Base.png',False))
    aImg.append(Load_Image('Barra.png',True))
    aImg.append(Load_Image('Carga.png',True))
    aImg.append(Load_Image('Garra.png',True))
    return aImg
 
def Pinta_Base():
    Panta.blit(aSprt[0],(0,0))
    return
 
def Pinta_Barra():
    Panta.blit(aSprt[1],(aBarra[0].nX,aBarra[0].nY))
    return
 
def Pinta_Carga():
    Panta.blit(aSprt[2],(111,268))
 
def Pinta_Garra():
    Panta.blit(aSprt[3],(108,277))
 
def Barra_Init():
    aBarra[0].nX = 7
    aBarra[0].nY = 280
    aBarra[0].nD = 0
    aBarra[0].nI = -1 # Sube
    aBarra[0].nT = nPAUSA
    return
 
def Pos_mouse():
    event = pygame.event.poll()
    if event.type == pygame.MOUSEBUTTONDOWN:
        return "(%d, %d)" % event.pos
 
Panta = PyGame_Init()
aSprt = Fig_Init()
aBarra = [ eBarra()]
aCarga = [ eCarga()]
aGarra = [ eGarra()]
Barra_Init()
while lOK:
    cKey = pygame.key.get_pressed()
    if cKey[pygame.K_ESCAPE]: lOK = False
    ev = pygame.event.get()
    for e in ev:
        if e.type == QUIT: lOK = False
    Pinta_Base()
    Pinta_Carga()
    Pinta_Barra()
    Pinta_Garra()
    pygame.display.flip()
    pygame.quit
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder