Jump to content
  • Advertisement
Sign in to follow this  
Pajari

Images in Python

This topic is 4662 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

I'm working on a simple turn-based strategy game in Python and I'm at the stage where all the gameplay rules have been set down and I'm coding the graphics engine. I'm throwing some images into the program to test it and IDLE is telling me that it's "too early" to create the images. I created them before I used them- what's early about that? Here's the method in question:
    def drawmap(self):
        grass = PhotoImage(file="grass.gif")
        rock = PhotoImage(file="rock.gif")
        tree = PhotoImage(file="tree.gif")
        field = PhotoImage(file="field.gif")
        
        for i in range(1, 11):
            for j in range(1, 11):
                if self.mapGrid[i*j] == "g":
                    self.drawarea.create_image(i*40, j*40, image = grass)
                elif self.mapGrid[i*j] == "r":
                    self.drawarea.create_image(i*40, j*40, image = rock)
                elif self.mapGrid[i*j] == "f":
                    self.drawarea.create_image(i*40, j*40, image = field)
                elif self.mapGrid[i*j] == "t":
                    self.drawarea.create_image(i*40, j*40, image = tree)
        print 'canvas drawn'

Share this post


Link to post
Share on other sites
Advertisement
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!