473,320 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

problem using pygame

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
1 1404
jlm699
314 100+
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

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

Similar topics

2
by: AnsNum | last post by:
hello, when I start this program, the movie doesn't play smoothly, anybody has an idea ? (I use windowsXP) import pygame from pygame.display import flip from pygame.locals import * ...
4
by: Sarah Mount | last post by:
Hi everyone. I'm trying to create an exe for a simple pygame app on Win XP. I think I've got the latest (python, py2exe, pygame) and my setup.py file looks like this: | from distutils.core...
1
by: liuliuliu | last post by:
hi -- sorry if this is trivial -- but how do you make a screenshot of a pygame display? i have a surface which is basically the entire visible screen -- how do you write this surface as an image...
11
by: dynamo | last post by:
Hi guys i have come again with more problems.This time it has to do with pygame.The following code does not give any error messages but it does not do what it is supposed to do either.the code is a...
1
by: koolest1 | last post by:
Im working in red hat linux 9.0. I've downloaded the pygame package but there is some problem while installing it. For the tar version, initial steps execute OK, namely, # tar xzvf...
0
by: Grant Edwards | last post by:
I've got a system where I try to install extensions using /usr/local/bin/python setup.py install But, it fails when it tries to use a non-existant compiler path and specs file. I suspect it's...
0
by: Michael Sparks | last post by:
Hi, Just thought some people may be interested to hear that I've recently been looking at adding true concurrency into Kamaelia, by using Paul Boddie's pprocess as the core mechanism to allow...
4
kaarthikeyapreyan
by: kaarthikeyapreyan | last post by:
I have installed pygame v 1.8.0 The installation was sucessful, but the optional packages were not included like the font,movie etc When i was trying to run the sample script that was given it...
3
by: globalrev | last post by:
im doing this : http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/ and when closing the program the window stays up and doesnt respond. i tried adding...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.