By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,483 Members | 3,229 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,483 IT Pros & Developers. It's quick & easy.

problem using pygame

P: 2
os version =windows xp
hi guys i'm having problems using pygame the following code just does not seem to work.
Expand|Select|Wrap|Line Numbers
  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[QUIT]:
  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)
May 27 '08 #1
Share this Question
Share on Google+
1 Reply


jlm699
100+
P: 314
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:
Expand|Select|Wrap|Line Numbers
  1. pygame.init()
  2.  
  3. size = [800,400]
  4. screen = pygame.display.set_mode(size)
May 28 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.