Pygame Help?

Started by
0 comments, last by flodihn 11 years, 11 months ago
Okay.. I am fairly new to pygame and I am having some serious issues. My goal is to create a game with an instruction screen that comes up upon game start and when the user clicks or pushes a button, it starts the game. Then when the user loses the game, it returns to the instruction screen.

How can I do this?

Here is what I have so far in this paste bin.

http://pastebin.com/cf5V4ExQ

The particular problem I am having is.. the turret which is in the bottom left hand corner.. is disfigured for what ever reason. When the user uses an arrow key, it is suppose to turn the turret. Also the program seems to be giving me this error.

line 77, in rotate
self.image = pygame.transform.rotate(self.image, self.dir)
error: Out of memory

no idea why this is happening. Someone please give me some guidance.. I hate being stumped. I was stumped on this for about 6 hours the other night.

here is also a picture, look at the turret in the bottom left hand corner. It seems really messed up :(
Advertisement
Always rotate from the original image, otherwise the image will become distorted.
So this will not work:

self.image = pygame.transform.rotate(self.image, self.dir)
[color=#000000][font=Consolas, Menlo, Monaco,] [/font]


Try doing something like this instead:

self.image = pygame.transform.rotate(self.original_image, self.dir)

And make sure orignal_image is created once in the __init__ function and never transformed.

You seem to create one new image every time you rotate the turret, which might be the reason why you run out of memory.

Do you run out of memory at once or after some time?
Do you run out of memory if you never rotate the turret?

You also try using Heapy:
http://guppy-pe.sour...y_tutorial.html

Just play the game as usual and print out the heapy stats each frame and look what objects are growing in number. If the issue would be how you deal with images, heapy would probably show objects like PyGame.Image or Pygame.Sprite in increasing number.

This topic is closed to new replies.

Advertisement