CS21 Lab 7: Extra Challenge: Memory Game with Zelle Graphics

For those of you about the make a graphical memory game, we salute you!

cards

Cards are images that you can load into Zelle, for example,

image = Image(Point(x,y), "card1.png")
print(image.getWidth()) # width in pixels
print(image.getHeight()) # height in pixels
imagePosition = image.getAnchor() # card center
image.draw(win) # show the card
image.undraw() # hide the card

In the demo, we show and hide cards based on the user’s mouse clicks.

positioning cards

Images have a width and height associated with them. You can use these values to check if the user clicked on a card. To reproduce the demo, create a window with size (1000, 800) and se the coords so that the origin is in the bottom left corner.

win = GraphWin("Memory Game", 1000, 800)
win.setCoords(0,0,1000,800)ire

The cards and text are positioned as follows:

memory zelle coords

demo