473,846 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem using pygame

2 New Member
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 1431
314 Contributor
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()
  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

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 * pygame.init()
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 import setup | import glob | import py2exe |
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 file during specific events in the script execution? image format doesnt matter. thanks! christine
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 bit long but it's straightforward.Please help import pygame from pygame.locals import * pygame.init() screen=pygame.display.set_mode((900,900)) class Hero(pygame.sprite.Sprite): def __init__(self): ...
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 pygame-1.7.1release.tar.gz # cd pygame-1.7.1release but after this: # ./configure bash: ./configure: No such file or directory So i don't hav a configure file? What should i do now?
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 trying to use the compieler that was used to build /usr/bin/python. How do I get it to use the compiler settings that were used for /usr/local/bin/python?
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 us to run multiple Kamaelia systems in the same app. (Since we have thread based, and co-operative generator based components, process based is the next logical step) http://kamaelia.sourceforge.net/Home
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 showed me this error $python fonty.py fonty.py:33: RuntimeWarning: use font: No module named font font = pygame.font.Font(None, 80) Traceback (most recent call last): File "fonty.py", line 89, in <module> if __name__ == '__main__': main()
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 this: http://www.pygame.org/wiki/FrequentlyAskedQuestions bu it doesnt work, or maybe im doing it wrong. heres the code without the added tutorial exit:
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.