pygame

Pygame: Blitting a moving background creates too much blur.

What I am trying to do is create a viewport to view a small portion of a background. (And later put sprites in). However the problem I have noticed is there seems to be an issue of the background blurring when it starts moving. I was not sure if this is because blitting is slow or because of a problem in the code. I was looking for exam...

Level Design in Pygame

Hey--I'm trying to design my first game using the Pygame library for Python, and I was wondering what the best practices are for level design in general. I would love to hear what you guys think are good object oriented design patterns for managing levels. Also, I'm fairly new to Python--thanks! ...

Overlapping partially transparent shapes

If I draw any shape onto a surface (with SRCALPHA flag on) in a partially transparent colour it completely replaces what was underneath it, instead of overlapping like you would expect in image editors. How can I make the shapes overlap properly? ...

Pygame in Windows: ImportError: DLL load failed

Hi, I just installed PyGame 1.9.1 (onto an existing python 2.6.4). Python and it standard libraries work, however, there is a problem with python even being able to find the pygame modules (correctly). Traceback (most recent call last): File "C:\foo\bar\firstGame.py", line 2, in <module> import pygame File "C:\python264\lib\sit...

Alternative pygame resources

Hi, I have been trying to access the pygame website for a few weeks now, and I can't get to it. I doubt it's down, so I have to conclude that it's blocked because I am in China. I have no idea why. Anyways, I want the pygame documentation, but all the download links I fond lead back to pygame.org (which I does not even begin loading, it'...

Pygame error: display surface quit: Why?

Sorry if this question is dumb, but I am writing from China and for some unfathomable reason a lot of websites having to do with pygame are blocked. I can't access pygame.org, I have not been able to download the docs or even look at message boards having to do with pygame! WEIRD! Anyways, I am a pygame newb and I need help with two thi...

Pygame programs hanging on exit

I'm tinkering around with pygame right now, and it seems like all the little programs that I make with it hang when I try to close them. Take the following code, for example: from pygame.locals import * pygame.init() # YEEAAH! tile_file = "blue_tile.bmp" SCREEN_SIZE = (640, 480) SCREEN_DEPTH = 32 if __name__ == "__main__": screen ...

Pygame integrated text editor

Hello, I am looking for an integrated pygame text editor, that is, something that can run in a pygame window without hijacking the event loop. I don't need anything fancy, just a basic editor. I have looked at pgu, and it is just barely ok, I am in the midst of modifying it to better suit my needs. Ocempgui is pretty cool, but seems a b...

How to suppress console output in Python?

I'm using Pygame/SDL's joystick module to get input from a gamepad. Every time I call its get_hat() method it prints to the console. This is problematic since I use the console to help me debug and now it gets flooded with SDL_JoystickGetHat value:0: 60 times every second. Is there a way I can disable this? Either through an option in Py...

pygame saving audio files

hi How can I convert a .wav file to some other format such as .mp3 in pygame? Update: Why not Gstreamer or Pygame: I want to use native Windows environment to install a package that can do this (i.e. don't want to install cygwin). I am searching for a package which has a binary installer available for windows (with Python 2.6) or at...

What's the best way to add a GUI to a pygame application?

Are there any good GUIs that support pygame surfaces as a widget within the application? If this isn't possible or practical, what GUI toolkit has the best graphics component? I'm looking to keep the speedy rendering made possible by a SDL wrapper. ...

What's the easiest way to reproduce a randomly generated level in Python?

I'm making a game which uses procedurally generated levels, and when I'm testing I'll often want to reproduce a level. Right now I haven't made any way to save the levels, but I thought a simpler solution would be to just reuse the seed used by Python's random module. However I've tried using both random.seed() and random.setstate() and ...

pygame audio playback speed

quick question. I'm running pygame under linux just to play some audio files. I've got some .wav files and I'm having problems playing them back at the right speed. import pygame.mixer, sys, time #plays too fast pygame.mixer.init(44100) pygame.mixer.music.load(sys.argv[1]) pygame.mixer.music.play() time.sleep(5) pygame.mixer.quit() ...

Using a python module's C API in my own C module

Hello. This seems to be sort of what I want, except I want to make an instance of a C PyObject in another C module. http://stackoverflow.com/questions/1147452/create-instance-of-a-python-class-declared-in-python-with-c-api But I am not able to find the documentation for using a Python module from C. I can't seem to find the relevent d...

Integrating pygame with a C module

In my Python2_6/include directory is a folder with pygame headers. I assumed that my python C module can access pygame stuff directly in C. Is this the case? How do I integrate a C module that wants to use pygame, with a python script using pygame? Right now my brain sees: pygame <-- MyCModule <-- MyScript --> pygame ie. Two pygame ins...

How to get rid of pygame surfaces?

In the following code, there is not just one circle on the screen at any given point in time. I want to fix this to make it so that it looks like there is only one circle, instead of leaving a smudge trail where ever the mouse cursor has been. import pygame,sys from pygame.locals import * pygame.init() screen = pygame.display.set_mode(...

Custom Events in pygame

Hello everyone, I'm having trouble getting my custom events to fire. My regular events work fine, but I guess I'm doing something wrong. Here is the relevant code: evt = pygame.event.Event(gui.INFOEVENT, {'time':time,'freq':freq,'db':db}) print "POSTING", evt pygame.event.post(evt) .... Later .... for event in pyga...

Pygame and threading: locked when accessing to globals?

Hi everyone. I am programming a game using pygame. I intend to control one of the characters using OpenSoundControl (OSC), a udp-based protocol for realtime communication. Basically I am using simpleOSC module to biund some OSC commands to functions on my pygame program. My game structure is something like this (this is a simplificatio...

PyGame Set Mouse Cursor from Bitmap

Hello everyone, I'm making an image editor using pyGame and I was wondering if it was possible to change the mouse cursor to something more suitable (for instance a circle or rectangle) for brushes. PyGame has a really weird way of doing it that I'm not sure would work very well. Is there a way I can write to a bitmap and then use that?...

Help finding longest non-repeating path through connected nodes - Python

I've been working on this for a couple of days now without success. Basically, I have a bunch of nodes arranged in a 2D matrix. Every node has four neighbors, except for the nodes on the sides and corners of the matrix, which have 3 and 2 neighbors, respectively. Imagine a bunch of square cards laid out side by side in a rectangular area...