pygame

Unicode fonts in PyGame

How can I display Chinese characters in PyGame? Also, what's a good free/libre font to use for this purpose? Thanks ...

Intercepting changes of attributes in classes within a class - Python

I have been messing around with pygame and python and I want to be able to call a function when an attribute of my class has changed. My current solution being: class ExampleClass(parentClass): def __init__(self): self.rect = pygame.rect.Rect(0,0,100,100) def __setattr__(self, name, value): parentClass.__setattr__(sel...

Python Desktop Integration - Drag and drop

I have a pygame window that I want to know when a file has been dragged and dropped onto it. I only need to be able to fetch the name of the file. How can this be accomplished? ...

pygame is screwing up ctypes

import mymodule, ctypes #import pygame foo = ctypes.cdll.MyDll.foo print 'success' if i uncomment the import pygame this fails with WindowsError: [Errno 182] The operating system cannot load %1. the stack frame is in ctypes python code, trying to load MyDll. win32 error code 182 is ERROR_INVALID_ORDINAL. if the pygame import is no...

Pygame Invalid Syntax I just can't figure out.

I've been following a tutorial "McGugan - Beginning Game Development with Python and Pygame (Apress, 2007)" and in the code at around chapter five involving object movement I keep getting invalid syntax alerts on '-' being used in the code. It isn't up to date but I would've thought a subtract wouldn't be changed in any updates due to it...

Pygame: Sprite changing due to direction of movement.

I've just started learning how to use pygame yesterday. I was read this one book that was super helpful and followed all its tutorials and examples and stuff. I wanted to try making a really simple side scroller/platforming game but the book sorta jumped pretty fast into 3D modeling with out instructing how to make changing sprites for m...

Pygame: Sprite animation Theory - Need Feedback

After some tweaking of some code I got from someone to cause a characters images to move in regards to its direction and up down left right input I've put this together: (hope the code isn't too messy) Character Move Code + IMG The Sprite sheet only runs lengthwise, so basically each sprite section is a different action. Now would ther...

How to add a second bouncing ball to the window?

I have coded an animation (in python) for a beach ball to bounce around a screen. I now wish to add a second ball to the window, and when the two collide for them to bounce off each other. So far, my attempts at this have been unsuccessful. Any ideas how to do this? The code I have so far is below. import pygame import sys if __nam...

Getting Aspen and Gheat on Windows working

Hi guys, I am not really familiar Python setup, I am trying to get gheat running on a Windows box, and it tells me it can't find pygame. I have tried Python25,26, older pygame version too. I have installed those as well as numpy as it has a dependency. Could someone with experience try and help me out getting it up and running. I ha...

Pygame - Different sided collision question!

Hi there everyone! I'm making a Pygame of, basically, "Breakout". I'm using collisions, and want a simple way to have different bounce effects of the different sides of one rectangle. What I currently have for the ball-to-bat collision is this: "dot" = ball; "bat" = bat; so you all understand. if dot.rect.colliderect(bat.rect):<br> dot...

Pygame cannot find include file "sdl.h"

I am trying to build a downloaded Python app on Windows that uses Pygame. I have installed Python 2.5 and Pygame 1.7.1. I am new to Python, but I just tried typing the name of the top level .py file on a Windows console command line. (I'm using Win XP Pro.) This is the message that I get. C:\Python25\include\pygame\pygame.h(68) : fa...

Can't create games with pygame

I make a game with python 2.5 and pygame. but,I can't complete make. because this errors occured. C:\Python26\TypeType\src\dist\Main.exe:8: RuntimeWarning: use font: MemoryLoadLibrary failed loading pygame\font.pyd Traceback (most recent call last): File "Main.py", line 8, in <module> File "pygame\__init__.pyo", line 70, in __getat...

Running Python code contained in a string

I'm writing a game engine using pygame and box2d, and in the character builder, I want to be able to write the code that will be executed on keydown events. My plan was to have a text editor in the character builder that let you write code similar to: if key == K_a: ## Move left pass elif key == K_d: ## Move right pass ...

Change window transparency in PyGame.

I want to change the transparency of a PyGame window. I don't nessicarly need to do this from PyGame as I already have an Python extension called wm_ext which controls the window which PyGame creates (it also initalizes PyGame). So, with this extension, I've got the window handle, I just need to know how to change the window transparen...

Updating one aspect of a Pygame surface

I have an application written in python that's basically an etch-a-sketch, you move pixels around with WASD and arrow keys and it leaves a trail. However, I want to add a counter for the amount of pixels on the screen. How do I have the counter update without updating the entire surface and pwning the pixel drawings? ...

Updating part of a surface in python, or transparent surfaces

I have an application written in python that's basically an etch-a-sketch, you move pixels around with WASD and arrow keys and it leaves a trail. However, I want to add a counter for the amount of pixels on the screen. How do I have the counter update without updating the entire surface and pwning the pixel drawings? Alternatively, can ...

How to avoid tearing with pygame on Linux/X11

I've been playing with pygame (on Debian/Lenny). It seems to work nicely, except for annoying tearing of blits (fullscreen or windowed mode). I'm using the default SDL X11 driver. Googling suggests that it's a known issue with SDL that X11 provides no vsync facility (even with a display created with FULLSCREEN|DOUBLEBUF|HWSURFACE flags...

game design - handling bonuses / duck typing - python

Hi! I am currently faced with a design problem in my game design, not terrible but it bothers me enough so I want to ask others opinions :-) I am currently experimenting with pygame, I have developed a little space shooter and now I would like to handle some bonuses. Right now I have an abstract class Bonus from which derive all the b...

What's a good way to render outlined fonts?

I'm writing a game in python with pygame and need to render text onto the screen. I want to render this text in one colour with an outline, so that I don't have to worry about what sort of background the the text is being displayed over. pygame.font doesn't seem to offer support for doing this sort of thing directly, and I'm wondering ...

Emulate processing with python?

I'm looking for a basic programmatic animation framework similar to processing except in python. That is, something that allows pixel manipulation, has basic drawing/color primitives, and is geared towards animation. Is pygame pretty much the best bet or are there other options? ...