import random
SIZE = 192
WIDTH = SIZE *7
HEIGHT =SIZE *3
pics = []
picks = []
picjs = []
for i in range(9):
pic=Actor("bdd"+str(i))
pick=Actor("bddk")
pick.index=i
pics.append(pic)
picks.append(pick)
random.shuffle(pics)
for j in range(9):
pics[j].left=(j%3+4)*SIZE
pics[j].top=j//3*SIZE
picks[j].left=(j%3)*SIZE
picks[j].top=j//3*SIZE
def draw():
screen.fill((255,255,255))
for pic in pics:
pic.draw()
for pick in picks:
pick.draw()
if finish:
sounds.win.play()
screen.draw.text("Finished!",center=(WIDTH//2,HEIGHT//2),fontsize=50,color="red")
def on_mouse_down(pos,button):
for pic in pics:
if button==mouse.LEFT and pic.collidepoint(pos):
picjs.append(pic)
for pick in picks:
if button==mouse.LEFT and pick.collidepoint(pos):
pick.image = picjs[-1].image
pics.remove(picjs[-1])
sounds.move.play()
def update():
global finish
finish = True
for pick in picks:
finish = finish and "bdd"+str(pick.index)==pick.image