I'm running Python 3.1 on Windows and I'm trying to distribute my Pygame script as an executable via cx_Freeze. Right now it seems to be working except that the exe build can't load any of my images:
Cannot load image: C:\path\to\build\exe.win32-3.1\resources\image.png
File is not a Windows BMP file
Googling has revealed that this hap...
I'm working on a Tetris-clone type game and I'm wondering what would be the best way to handle the logic that moves the blocks down every N seconds. I initially did it the easy way:
pygame.time.set_timer(USEREVENT+1, 300)
This will of course add a PyGame event to the queue every 300 milliseconds. In the main loop I can test for this e...
I have a method in a Pygame Sprite subclass, defined as such:
def walk(self):
"""move across screen"""
displacement = self.rect.move((self.move, 0))
if self.rect.left < self.area.left or self.rect.right > self.area.right:
self.move = -self.move
displacement = self.rect.move((self.move, 0))
self.rect = dis...
Given a string containing jpeg image data, is it possible to load this directly in pygame?
I've tried using StringIO but failed and I don't completely understand the 'file-like' object concept.
Currently, as a workaround, I'm saving to disk and then loading an image the standard way:
# imagestring contains a jpeg
f=open('test.jpg','w...
I'm still learning python and after playing around with pygame I noticed I'm re-importing things in modules I'm importing that I've already imported.
import pygame
For instance I have some classes in a separate file, but I must also import pygame into that file too for them to work. Does it actually import the code twice? Will it slow...
I'm trying to play sound files (.wav) with pygame but when I start it I never hear anything.
This is the code:
import pygame
pygame.init()
pygame.mixer.init()
sounda= pygame.mixer.Sound("desert_rustle.wav")
sounda.play()
I also tried using channels but the result is the same
...
I want to use a pyGame program as a part of another process. Using the following code, pyGame doesn't seem to be processing events; it doesn't respond to the 'q' key nor does it draw the titlebar for the window. If go() is not run as a thread, it works fine. This is under OSX; I'm unsure if that's the problem or not.
import pygame, thre...
I am trying to make a web browser using pygame. I am using PGU for html rendering. It works fine when I visit simple sites, like example.com, but when I try and load anything more complex that uses an html form, like google, I get this error:
UnboundLocalError: local variable 'e' referenced before assignment
I looked in the PGU html r...
I have a 2D list of vectors (say 20x20 / 400 points) and I am drawing these points on a screen like so:
for row in grid:
for point in row:
pygame.draw.circle(window, white, (particle.x, particle.y), 2, 0)
pygame.display.flip() #redraw the screen
This works perfectly, however it's much slower then I expected.
I want to...
hello friends,
i am jaison i like to build an application for land survey process. for that i need to plot points in a canvas for a given gsi file. for example
the points be
a. .b
c. .d .e
these are the 5 points and i need to develop a tool to connect these points by line. while closin...
The following program loads two images with PyGame, converts them to Numpy arrays, and then performs some other Numpy operations (such as FFT) to emit a final result (of a few numbers). The inputs can be large, but at any moment only one or two large objects should be live.
A test image is about 10M pixels, which translates to 10MB onc...
Hi,
I'm writing a game with using Pygame. The background of the game is a mpeg video and I draw
a blank layer on this mpeg video. However to make visible the blank page all the time, I need to close the clock.tick function. As you can see without clock.tick() function my animations became too fast.
So I want to draw a layer on an mpe...
I've just started to learn pygame, and it pretty much needs some coordinates and points in the code in order to position the object. Do you know of any tool or application that I could use as a reference so that I could see a visual representation of the points.
Maybe a grid with numbers.
And pygame also includes declaring the color by...
I'm completely new to python (and it's been a while since I've coded much).
I'm trying to call a method which acts as an event handler in a little "hello world" type game, but it's not working at all. I'm using the pygames 1.9.1 lib with python 2.6.1 on OSX 10.6.3.
So this is in a while loop:
self.exitCheck()
if sel...
Hi there,
I am using Pygame to pageflip different stimuli on the screen. The problem is that pygame's flip function, although syncing the flip to the vertical retrace, does not tell me when the retrace was.
Does anyone know of a way to get this information (preferably platform independent) in Python?
Regards,
fladd
...
Hello. I am running in ubuntu and I can code in python, without problem. I have tried to install pygame and to do make it so, I did:
sudo apt-get instal python-pygame
When I go into the python IDLE and write:
import pygame
I get:
Traceback (most recent call last):
File "", line 1, in
ImportError: No module name...
I made a program similar to the second PyODE tutorial but using VPython instead of pygame and I removed the coord function for changing coordinates. It works but the locating of the spheres and joints isn't correct. I am guessing that it is because I am using the PyODE world coordinates within VPython. Would this in the circumstance I de...
What would be the best way to use negative coordinates in pygame?
At the moment I have a surface that is 1.5 times the original surface then everything that needs to be drawn is shifted up by a certain amount (to ensure the negative coordinates become positive) and drawn.
Is there an easier/alternate way of doing this?
...
I'm trying to add some gui elements (dialog boxes with buttons) to a game I'm writing with pygame. I looked around for a decent gui toolkit and ended up with pgu. Anyway, I'm trying to get it to pop up a dialog box, which it does (sort of), but it isn't closing.
Here's a simplified version of my code that just shows the behavior I care ...
I'm currently trying to write a multiple-file Python (2.6.5) game using PyGame. The problem is that one of the files, "pyconsole.py", needs to be able to call methods on instances of other objects imported by the primary file, "main.py". The problem is that I have a list in the main file to hold instances of all of the game objects (pl...