Jump to content
  • Advertisement
Sign in to follow this  
Robocop413

Pygame Help?

This topic is 2355 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
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. Edited by flodihn

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!