Sign in to follow this  

Pygame Help?

This topic is 2050 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 :(

Share this post


Link to post
Share on other sites
Always rotate from the original image, otherwise the image will become distorted.
So this will not work:
[CODE]
self.image = pygame.transform.rotate(self.image, self.dir)
[/CODE][color=#000000][font=Consolas, Menlo, Monaco,] [/font][/color]


Try doing something like this instead:
[CODE]
self.image = pygame.transform.rotate(self.original_image, self.dir)
[/CODE]
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:
[url="http://guppy-pe.sourceforge.net/heapy_tutorial.html"]http://guppy-pe.sour...y_tutorial.html[/url]

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. Edited by flodihn

Share this post


Link to post
Share on other sites

This topic is 2050 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this