problem using pygame

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • joshuabraham
    New Member
    • May 2008
    • 2

    problem using pygame

    os version =windows xp
    hi guys i'm having problems using pygame the following code just does not seem to work.
    Code:
    clock=pygame.time.Clock()
    while True:
        sound1.play()
        clock.tick(60)
        pKeys = pygame.key.get_pressed()
        Eves=pygame.event.get()
        villian.face()
        villian.hert()
        if Eves[KEYDOWN] and pKeys[K_UP]:
            hero.moveup()
        if Eves[KEYUP] and pKeys[K_UP]:
            hero.gravity()
        if Eves[KEYDOWN] and pKeys[K_DOWN]:
            hero.movedown()
        if Eves[KEYDOWN] and pKeys[K_RIGHT]:
            hero.forward()
        if Eves[KEYDOWN] and pKeys[K_LEFT]:
            hero.back()
        if Eves[KEYDOWN] and pKeys[97]:
            sound.play()
            hero.reShape()
        if Eves[KEYUP] and pKeys[97]:
            hero.Shape()
        if Eves[KEYDOWN] and pKeys[115]:
            hero.Kick()
        if Eves[QUIT]:
            pygame.quit()
            raise SystemExit()
        allsprites.update()
        screen.blit(background,(0,0))
        allsprites.draw(screen)
        pygame.display.flip()
        time.sleep(1/30)
  • jlm699
    Contributor
    • Jul 2007
    • 314

    #2
    What does not work? This code is not complete so I don't know what problems you are having with it. Just from this code I would say that you did not import pygame as your first problem. Second problem is that you do not initialize sound1, villian, hero, KEYDOWN, KEYUP, etc. Third problem is that you never instantiated a pygame instance.
    To begin a pygame interface you need something like this:
    [code=python]
    pygame.init()

    size = [800,400]
    screen = pygame.display. set_mode(size)[/code]

    Comment

    Working...