Skip to main content
gamedev.net
🔒 Locked

Images in Python

Started by Pajari Dec 18, 2005 at 4:56 PM 0 replies 600+ views
Original Post
Pajari
Pajari
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'
CoMaNdore
CoMaNdore
I think you need to create a [Tk] Object before using anything
Me

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.