Pacman sur Python
helpneeded1
-
Naheulf Messages postés 287 Date d'inscription Statut Membre Dernière intervention -
Naheulf Messages postés 287 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Je suis debutante en Python3 et je me suis lance le defi de dessiner un Pacman sur Tkinter. J ai reussi apres un long moment, et maintenant je voudrais l animer. J avais donc pense a creer 2 arcs, n pour la bouche ouverte et un pour la bouche fermee du personnage, et en animer tantot l un tantot l autre selon la position. Mais resultat, plus rien ne s'anime et je ne comprends pas ou ca bloque.
Qu'en pensez vous ?
Merci.
import tkinter
import time
top = tkinter.Tk()
C = tkinter.Canvas(top, bg="white", height=500, width=600)
coord = 30, 30, 200, 200
coord1 = 14, 520, 30, 21
arcouvert = C.create_arc(coord, start=30, extent=300, fill="yellow")
arc1 = C.create_oval(90, 90, 100, 100, fill="black", width=2)
arc2 = C.create_oval(155, 130, 185, 100, fill="yellow", width=2)
arc3 = C.create_oval(255, 100, 285, 130, fill="yellow", width=2)
arc4 = C.create_oval(355, 100, 385, 130, fill="yellow", width=2)
tetePos = 0
if 155 < tetePos :
tetePos=tetePos+10;
C.move(arcouvert, 10, 0)
C.move(arc1, 10, 0)
time.sleep(0.5)
C.update()
elif 255 < tetePos > 285:
tetePos=tetePos+10;
C.move(arcouvert, 10, 0)
C.move(arc1, 10, 0)
time.sleep(0.5)
C.update()
elif 355 < tetePos > 385:
tetePos=tetePos+10;
C.move(arcouvert, 10, 0)
C.move(arc1, 10, 0)
time.sleep(0.5)
C.update()
else:
arcferme = C.create_arc(coord, start=1, extent=359, fill="yellow")
C.delete(arcouvert)
C.move(arcferme, 10, 0)
C.move(arc1, 10, 0)
C.update()
C.pack()
top.mainloop()
Je suis debutante en Python3 et je me suis lance le defi de dessiner un Pacman sur Tkinter. J ai reussi apres un long moment, et maintenant je voudrais l animer. J avais donc pense a creer 2 arcs, n pour la bouche ouverte et un pour la bouche fermee du personnage, et en animer tantot l un tantot l autre selon la position. Mais resultat, plus rien ne s'anime et je ne comprends pas ou ca bloque.
Qu'en pensez vous ?
Merci.
import tkinter
import time
top = tkinter.Tk()
C = tkinter.Canvas(top, bg="white", height=500, width=600)
coord = 30, 30, 200, 200
coord1 = 14, 520, 30, 21
arcouvert = C.create_arc(coord, start=30, extent=300, fill="yellow")
arc1 = C.create_oval(90, 90, 100, 100, fill="black", width=2)
arc2 = C.create_oval(155, 130, 185, 100, fill="yellow", width=2)
arc3 = C.create_oval(255, 100, 285, 130, fill="yellow", width=2)
arc4 = C.create_oval(355, 100, 385, 130, fill="yellow", width=2)
tetePos = 0
if 155 < tetePos :
tetePos=tetePos+10;
C.move(arcouvert, 10, 0)
C.move(arc1, 10, 0)
time.sleep(0.5)
C.update()
elif 255 < tetePos > 285:
tetePos=tetePos+10;
C.move(arcouvert, 10, 0)
C.move(arc1, 10, 0)
time.sleep(0.5)
C.update()
elif 355 < tetePos > 385:
tetePos=tetePos+10;
C.move(arcouvert, 10, 0)
C.move(arc1, 10, 0)
time.sleep(0.5)
C.update()
else:
arcferme = C.create_arc(coord, start=1, extent=359, fill="yellow")
C.delete(arcouvert)
C.move(arcferme, 10, 0)
C.move(arc1, 10, 0)
C.update()
C.pack()
top.mainloop()