hi guys,when i run my program which contains the following portion of code in the mainloop
Code: ( text )

1.
      clock=pygame.time.Clock()
   2.
      while True:
   3.
          sound1.play()
   4.
          clock.tick(60)
   5.
          pKeys = pygame.key.get_pressed()
   6.
          Eves=pygame.event.get()
   7.
          villian.face()
   8.
          villian.hert()
   9.
          if Eves[KEYDOWN] and pKeys[K_UP]:
  10.
              hero.moveup()
  11.
          if Eves[KEYUP] and pKeys[K_UP]:
  12.
              hero.gravity()
  13.
          if Eves[KEYDOWN] and pKeys[K_DOWN]:
  14.
              hero.movedown()
  15.
          if Eves[KEYDOWN] and pKeys[K_RIGHT]:
  16.
              hero.forward()
  17.
          if Eves[KEYDOWN] and pKeys[K_LEFT]:
  18.
              hero.back()
  19.
          if Eves[KEYDOWN] and pKeys[97]:
  20.
              sound.play()
  21.
              hero.reShape()
  22.
          if Eves[KEYUP] and pKeys[97]:
  23.
              hero.Shape()
  24.
          if Eves[KEYDOWN] and pKeys[115]:
  25.
              hero.Kick()
  26.
          if Eves[0]:
  27.
              pygame.quit()
  28.
              raise SystemExit()
  29.
          allsprites.update()
  30.
          screen.blit(background,(0,0))
  31.
          allsprites.draw(screen)
  32.
          pygame.display.flip()
  33.
          time.sleep(1/30)

i get this error
Code: ( text )

1.
      Traceback (most recent call last):
   2.
        File "C:\Python24\RealSuperDynamo.py", line 145, in ?
   3.
          if Eves[KEYDOWN] and pKeys[K_UP]:
   4.
      IndexError: list index out of range

hi guys,when i run my program which contains the following portion of code in the mainloop

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[0]:
              pygame.quit()
              raise SystemExit()
          allsprites.update()
          screen.blit(background,(0,0))
          allsprites.draw(screen)
          pygame.display.flip()
          time.sleep(1/30)

List index is out of range. You are not using Eves and pKeys correctly.
Can you post how you're initializing you game space for curiosity's sake?

This article has been dead for over six months. Start a new discussion instead.