[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] key refrence~



So, I write code like your style but get another response. this is my code below :

while 1 :
    ev=pygame.key.get_pressed()
    if ev[pygame.K_LEFT] :
        posX-=50
        screen.blit(pic, (posX, posY))
        pygame.display.update()
    elif ev[pygame.K_RIGHT]:
        posX+=50
        screen.blit(pic, (posX, posY))
        pygame.display.update()

as you see I just want to move my picture, 50 pixels left when left key is pressed and 50 pixels right when right key is pressed. but it refuse to move when testing. anyone could point out where the error is ? thanx~

 Balki <schmalki@ntlworld.com> wrote:

do something like:

pygame.event.pump()
keys=pygame.key.get_pressed()
if keys[K_ESCAPE] or pygame.event.peek(QUIT):
break
if keys[K_LEFT]:
#code for moving left here

cheers,
Andy


On Fri, 2002-10-18 at 09:49, black wrote:
>
> First of all, thanx Pete and Fredrik and Jesse and other kind people who helped me with my basic questions. Fortunately now I can create a nice background and add pictures to it and move them, as I said before my destination is to make games, so the next step is to contol those character(surface) which attached to background. my code is like this:
>
> ev=pygame.event.wait()
> if ev.type==pygame.KEYDOWN :
> break
>
> I searched Key and Event manual but only find event types. where does those key reference live ? for example I need a surface moving 10 pixel when left key is pressed.
>
> thanx~
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Faith Hill - Exclusive Performances, Videos, & more
> faith.yahoo.com


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org



Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site