Sign in to follow this  

Images in Python

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

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