Map en BITMAP

Fermé
Yazho Messages postés 85 Date d'inscription dimanche 24 mars 2019 Statut Membre Dernière intervention 14 septembre 2022 - Modifié le 23 mai 2020 à 19:23
Yazho Messages postés 85 Date d'inscription dimanche 24 mars 2019 Statut Membre Dernière intervention 14 septembre 2022 - 24 mai 2020 à 11:44
Bonjour alors j'ai une question importante je vous met dans le contexte j'ai un projet a faire en informatique je dois créer une petit jeu grace a des matrices et en bitmap. Pour l'instant j'ai reussi a placer le personnage a le faire bouger a travers ma map et un moment je le fais rentrer dans une maison et j'aimerais que la map disparraisse pour laissez place a l'interieur de la maison pour que le personnage se deplace aussi dedans et voilà mon probleme je ne sais pas vraiment comment m'y prendre j'ai essayé de créer un deuxieme canevas et d'effacer le premier mais je ne pouvais pas bouger mon personnage vous pouvez voir ci-dessous et donc je ne sais pas si il faut que je garde 1 canevas ou bien que je créer une autre fenetre a vous de me dire j'éspere que j'ai été clair merci de votre aide
Ps: je suis sur pyscripter avec le module tkinter
voilà le code:
#creation d'une bitmap
#modules
from tkinter import *
#creation de la fenetre

Mafenetre=Tk()
Mafenetre.geometry('800x900')

#zone de dessin
can2=Canvas(Mafenetre,bg="white",width=400,height=400)
can2.place(x=0,y=0)
can1=Canvas(Mafenetre,bg="white",width=800,height=900)
can1.place(x=0,y=0)

#creation des cases images
casecerisier=PhotoImage(file="cerisier.gif")
casesolj=PhotoImage(file="soljapon.gif")
casesoljG=PhotoImage(file="soljaponG.gif")
casesoljD=PhotoImage(file="soljaponD.gif")
casesoljH=PhotoImage(file="soljaponH.gif")
casesoljB=PhotoImage(file="soljaponB.gif")
casesoljY=PhotoImage(file="soljaponY.gif")
caseeau=PhotoImage(file="eau.gif")
caseeaupoisson=PhotoImage(file="eaupoisson.gif")
caseaeroNO=PhotoImage(file="aeroport NO.gif")
caseaeroNE=PhotoImage(file="aeroport NE.gif")
caseaeroSO=PhotoImage(file="aeroport SO.gif")
caseaeroSE=PhotoImage(file="aeroport SE.gif")
casemaisonhkNO=PhotoImage(file="maisonhk NO.gif")
casemaisonhkNE=PhotoImage(file="maisonhk NE.gif")
casemaisonhkSO=PhotoImage(file="maisonhk SO.gif")
casemaisonhkSE=PhotoImage(file="maisonhk SE.gif")
casemaisonNO=PhotoImage(file="maisonNO.gif")
casemaisonNE=PhotoImage(file="maisonNE.gif")
casemaisonSO=PhotoImage(file="maisonSO.gif")
casemaisonSE=PhotoImage(file="maisonSE.gif")
casepagodeNO=PhotoImage(file="pagodeNO.gif")
casepagodeNE=PhotoImage(file="pagodeNE.gif")
casepagodeSO=PhotoImage(file="pagodeSO.gif")
casepagodeSE=PhotoImage(file="pagodeSE.gif")
casesushiNO=PhotoImage(file="sushiNO.gif")
casesushiNE=PhotoImage(file="sushiNE.gif")
casesushiSO=PhotoImage(file="sushiSO.gif")
casesushiSE=PhotoImage(file="sushiSE.gif")
casepagodejNO=PhotoImage(file="pagodejNO.gif")
casepagodejNE=PhotoImage(file="pagodejNE.gif")
casepagodejSO=PhotoImage(file="pagodejSO.gif")
casepagodejSE=PhotoImage(file="pagodejSE.gif")
caseyoshi=PhotoImage(file="yoshi2.gif")
caseherbe=PhotoImage(file="herbe.gif")
casebleu=PhotoImage(file="bleu.gif")
persoD1=PhotoImage(file="bonhommeD1.gif")
persoD2=PhotoImage(file="bonhommeD2.gif")
persoG1=PhotoImage(file="bonhommeG1.gif")
persoG2=PhotoImage(file="bonhommeG2.gif")
caseeau=PhotoImage(file="eau.gif")
casepont=PhotoImage(file="pont.gif")
casevillage=PhotoImage(file="village.gif")
caseparquet=PhotoImage(file="parquet.gif")
caseparquetp=PhotoImage(file="parquetp.gif")
casemur=PhotoImage(file="mur.gif")
casefenetreh=PhotoImage(file="fenetreh.gif")
casefenetreb=PhotoImage(file="fenetreb.gif")
casechatNO=PhotoImage(file="chatNO.gif")
casechatNE=PhotoImage(file="chatNE.gif")
casechatSO=PhotoImage(file="chatSO.gif")
casechatSE=PhotoImage(file="chatSE.gif")
caselith=PhotoImage(file="lith.gif")
caselitb=PhotoImage(file="litb.gif")
casetableNO=PhotoImage(file="tableNO.gif")
casetableNE=PhotoImage(file="tableNE.gif")
casetableSO=PhotoImage(file="tableSO.gif")
casetableSE=PhotoImage(file="tableSE.gif")
tab_droite=[persoD1,persoD2]
tab_gauche=[persoG1,persoG2]
compteur_de_pas=0
#creation de la matrice
L0=["ANO","ANE","SH","T","T","T","T","T","PNO","PNE","JNO","JNE","PNO","PNE","JNO","JNE"]
L1=["ASO","ASE","SB","T","T","T","T","T","PSO","PSE","JSO","JSE","PSO","PSE","JSO","JSE"]
L2=["C","C","C","C","C","C","T","T","C","E","E","E","E","E","PO","E"]
L3=["C","C","C","C","C","C","T","T","C","C","C","C","C","C","C","E"]
L4=["T","T","T","T","T","T","T","T","T","T","T","T","T","T","C","H"]
L5=["T","T","T","T","T","T","T","T","SG","SD","T","T","T","T","C","H"]
L6=["T","T","C","C","C","C","T","SY","SNO","SNE","C","C","T","T","C","H"]
L7=["T","T","C","JNO","JNE","C","T","T","SSO","SSE","C","C","T","T","C","H"]
L8=["T","T","C","JSO","JSE","C","T","T","C","C","C","C","SG","SD","C","H"]
L9=["T","SY","Y","C","C","C","T","T","C","PNO","PNE","C","MNO","MNE","C","H"]
L10=["C","C","C","C","C","C","T","T","C","PSO","PSE","C","MSO","MSE","C","H"]
L11=["H","H","H","H","H","H","T","T","C","C","C","C","C","C","C","H"]
L12=["H","E","E","E","E","H","T","T","T","T","T","T","C","E","C","H"]
L13=["H","E","E","E","PO","H","T","T","T","T","SG","SD","C","PO","C","H"]
L14=["H","H","H","H","H","H","C","C","C","C","HNO","HNE","C","E","C","H",]
L15=["C","C","C","C","C","C","C","C","C","C","HSO","HSE","C","C","C","H",]
L0P=["M","FH","M","FH","FH","M","FH","M"]
L1P=["M","FB","M","FB","FB","M","FB","M","M"]
L2P=["LH","LH","PA","PA","PA","PA","CNO","CNE",]
L3P=["LB","LB","PA","PA","PA","PA","CSO","CSE",]
L4P=["PA","PA","PA","PA","PA","PA","PA","PA",]
L5P=["PA","TNO","TNE","PA","PA","PA","PA","PA",]
L6P=["PA","TSO","TSE","PA","PA","PA","PA","PA",]
L7P=["PA","PA","PA","PA","PA","PAP","PA","PA",]
japon=[L0,L1,L2,L3,L4,L5,L6,L7,L8,L9,L10,L11,L12,L13,L14,L15]
maison_interior=[L0P,L1P,L2P,L3P,L4P,L5P,L6P,L7P]
#creation de la map
dico={"SG":casesoljG,"SY":casesoljY,"SD":casesoljD,"SH":casesoljH,"SB":casesoljB,"B":casebleu,"H":caseherbe,"C":casecerisier,"ANO":caseaeroNO,"ANE":caseaeroNE,"ASO":caseaeroSO,"ASE":caseaeroSE,"HNO":casemaisonhkNO,"HNE":casemaisonhkNE,"HSO":casemaisonhkSO,
"SNO":casesushiNO,"SNE":casesushiNE,"SSO":casesushiSO,"SSE":casesushiSE,"PNO":casepagodeNO,"PNE":casepagodeNE,"PSO":casepagodeSO,"PSE":casepagodeSE,
"MNO":casemaisonNO,"MNE":casemaisonNE,"MSO":casemaisonSO,"MSE":casemaisonSE,"HSE":casemaisonhkSE,"T":casesolj,"E":caseeau,"PO":caseeaupoisson,
"JNO":casepagodejNO,"JNE":casepagodejNE,"JSO":casepagodejSO,"JSE":casepagodejSE,"Y":caseyoshi,"PON":casepont,"V":casevillage,"PA":caseparquet,"PAP":caseparquetp,"M":casemur,"FH":casefenetreh,"FB":casefenetreb,
"CNO":casechatNO,"CNE":casechatNE,"CSO":casechatSO,"CSE":casechatSE,"LH":caselith,"LB":caselitb,"TNO":casetableNO,"TNE":casetableNE,"TSO":casetableSO,"TSE":casetableSE}
for i in range(16):
for j in range(16):
can1.create_image(50*j,50*i,image=dico[japon[i][j]],anchor="nw")

#position du personnage
posX=100 #abscisse de depart
posY=0
#ordonne de depart
perso=can1.create_image(posX,posY,image=persoD1,anchor="nw")
#zones de texte
texte_pnj=can1.create_text(350,850,text="",font=("Arial",13),fill="black")




def Clavier(event):
#event recupre l'information tapée sur le clavier
global posX,posY
touche=event.keysym
colonne=posX//50
ligne=posY//50
if touche=='Up' and japon[ligne-1][colonne]!="C":
mvt_haut()
if touche=='Down' and japon[ligne+1][colonne]!="C":
mvt_bas()
if touche=="Right" and japon[ligne][colonne+1]!="C":
mvt_droite()
if touche=="Left" and japon[ligne][colonne-1]!="C":
mvt_gauche()

def mvt_gauche():
"""deplace   gauche le perso"""
global perso,posX,posY,compteur_de_pas,texte_pnj
posX=posX-50
if posX<0 :
posX=00
#mise à  jour de l'image
can1.itemconfig(perso,image=tab_gauche[compteur_de_pas%2])
compteur_de_pas+=1
#mise à jour des coordonnes
can1.coords(perso,posX,posY)

def mvt_haut():
"""deplace le perso vers le haut"""
global perso,posY,posX,compteur_de_pas
posY=posY-50
if posY<0 :
posY=0
#mise à jour de l'image
can1.itemconfig(perso,image=tab_gauche[compteur_de_pas%2])
compteur_de_pas+=1
#mise jour des coordonnées
can1.coords(perso,posX,posY)

def mvt_bas():
"""deplace le perso vers le haut"""
global perso,posY,posX,compteur_de_pas
posY=posY+50
if posY<0 :
posY=0
#mise   jour de l'image
can1.itemconfig(perso,image=tab_gauche[compteur_de_pas%2])
compteur_de_pas+=1
#mise à jour des coordonnées
can1.coords(perso,posX,posY)
if posX==400 and posY==350 :
can1.itemconfig(texte_pnj,text="test 1")
if posX==450 and posY==300 :
can1.itemconfig(texte_pnj,text="test 1")
if posX==500 and posY==700 :
can1.itemconfig(texte_pnj,text=" test 2r")
if posX==550 and posY==700 :
can1.itemconfig(texte_pnj,text=" test2")
if posX==600 and posY==450 :
can1.after(100,maison)
if posX==650 and posY==450 :
can1.after(100,maison)


def mvt_droite():
"""deplace à droite le perso"""
global perso,posX,posY,compteur_de_pas
posX=posX+50
if posX>800 :
posX=800
#mise à  jour de l'image
can1.itemconfig(perso,image=tab_droite[compteur_de_pas%2])
compteur_de_pas+=1
#mise à jour des coordonnes
can1.coords(perso,posX,posY)
if posX==100 and posY==450 :
can1.itemconfig(texte_pnj,text="test")
if posX==400 and posY==350 :
can1.itemconfig(texte_pnj,text="test")
if posX==400 and posY==300 :
can1.itemconfig(texte_pnj,text="test")

def maison():
global perso,posX,posY,compteur_de_pas
Mafenetre.geometry('400x400')
can1.destroy()
for i in range(8):
for j in range(8):
can2.create_image(50*j,50*i,image=dico[maison_interior[i][j]],anchor="nw")
posX=250 #abscisse depart
posY=350
#ordonnée de depart
perso2=can2.create_image(posX,posY,image=persoD1,anchor="nw")




#programme principal


can1.focus_set()
can1.bind('<Key>',Clavier)


Mafenetre.mainloop()

A voir également:

2 réponses

Phil_1857 Messages postés 1872 Date d'inscription lundi 23 mars 2020 Statut Membre Dernière intervention 28 février 2024 168
24 mai 2020 à 10:50
Bonjour Yazho,

L'indentation étant importante en Python, pourrais-tu appliquer les balises de code à ton script:

Le mode d'emploi:

https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code
0
Yazho Messages postés 85 Date d'inscription dimanche 24 mars 2019 Statut Membre Dernière intervention 14 septembre 2022 2
24 mai 2020 à 11:44
Voilà excusez moi de ne pas l'avoir fait avant
#creation d'une bitmap
#modules
from tkinter import *
#creation de la fenetre

Mafenetre=Tk()
Mafenetre.geometry('800x900')

#zone de dessin
can2=Canvas(Mafenetre,bg="white",width=400,height=400)
can2.place(x=0,y=0)
can1=Canvas(Mafenetre,bg="white",width=800,height=900)
can1.place(x=0,y=0)

#creation des cases images
casecerisier=PhotoImage(file="cerisier.gif")
casesolj=PhotoImage(file="soljapon.gif")
casesoljG=PhotoImage(file="soljaponG.gif")
casesoljD=PhotoImage(file="soljaponD.gif")
casesoljH=PhotoImage(file="soljaponH.gif")
casesoljB=PhotoImage(file="soljaponB.gif")
casesoljY=PhotoImage(file="soljaponY.gif")
caseeau=PhotoImage(file="eau.gif")
caseeaupoisson=PhotoImage(file="eaupoisson.gif")
caseaeroNO=PhotoImage(file="aeroport NO.gif")
caseaeroNE=PhotoImage(file="aeroport NE.gif")
caseaeroSO=PhotoImage(file="aeroport SO.gif")
caseaeroSE=PhotoImage(file="aeroport SE.gif")
casemaisonhkNO=PhotoImage(file="maisonhk NO.gif")
casemaisonhkNE=PhotoImage(file="maisonhk NE.gif")
casemaisonhkSO=PhotoImage(file="maisonhk SO.gif")
casemaisonhkSE=PhotoImage(file="maisonhk SE.gif")
casemaisonNO=PhotoImage(file="maisonNO.gif")
casemaisonNE=PhotoImage(file="maisonNE.gif")
casemaisonSO=PhotoImage(file="maisonSO.gif")
casemaisonSE=PhotoImage(file="maisonSE.gif")
casepagodeNO=PhotoImage(file="pagodeNO.gif")
casepagodeNE=PhotoImage(file="pagodeNE.gif")
casepagodeSO=PhotoImage(file="pagodeSO.gif")
casepagodeSE=PhotoImage(file="pagodeSE.gif")
casesushiNO=PhotoImage(file="sushiNO.gif")
casesushiNE=PhotoImage(file="sushiNE.gif")
casesushiSO=PhotoImage(file="sushiSO.gif")
casesushiSE=PhotoImage(file="sushiSE.gif")
casepagodejNO=PhotoImage(file="pagodejNO.gif")
casepagodejNE=PhotoImage(file="pagodejNE.gif")
casepagodejSO=PhotoImage(file="pagodejSO.gif")
casepagodejSE=PhotoImage(file="pagodejSE.gif")
caseyoshi=PhotoImage(file="yoshi2.gif")
caseherbe=PhotoImage(file="herbe.gif")
casebleu=PhotoImage(file="bleu.gif")
persoD1=PhotoImage(file="bonhommeD1.gif")
persoD2=PhotoImage(file="bonhommeD2.gif")
persoG1=PhotoImage(file="bonhommeG1.gif")
persoG2=PhotoImage(file="bonhommeG2.gif")
caseeau=PhotoImage(file="eau.gif")
caseparquet=PhotoImage(file="parquet.gif")
caseparquetp=PhotoImage(file="parquetp.gif")
casemur=PhotoImage(file="mur.gif")
casefenetreh=PhotoImage(file="fenetreh.gif")
casefenetreb=PhotoImage(file="fenetreb.gif")
casechatNO=PhotoImage(file="chatNO.gif")
casechatNE=PhotoImage(file="chatNE.gif")
casechatSO=PhotoImage(file="chatSO.gif")
casechatSE=PhotoImage(file="chatSE.gif")
caselith=PhotoImage(file="lith.gif")
caselitb=PhotoImage(file="litb.gif")
casetableNO=PhotoImage(file="tableNO.gif")
casetableNE=PhotoImage(file="tableNE.gif")
casetableSO=PhotoImage(file="tableSO.gif")
casetableSE=PhotoImage(file="tableSE.gif")

tab_droite=[persoD1,persoD2]
tab_gauche=[persoG1,persoG2]
compteur_de_pas=0
#creation de la matrice
L0=["ANO","ANE","SH","T","T","T","T","T","PNO","PNE","JNO","JNE","PNO","PNE","JNO","JNE"]
L1=["ASO","ASE","SB","T","T","T","T","T","PSO","PSE","JSO","JSE","PSO","PSE","JSO","JSE"]
L2=["C","C","C","C","C","C","T","T","C","E","E","E","E","E","PO","E"]
L3=["C","C","C","C","C","C","T","T","C","C","C","C","C","C","C","E"]
L4=["T","T","T","T","T","T","T","T","T","T","T","T","T","T","C","H"]
L5=["T","T","T","T","T","T","T","T","SG","SD","T","T","T","T","C","H"]
L6=["T","T","C","C","C","C","T","SY","SNO","SNE","C","C","T","T","C","H"]
L7=["T","T","C","JNO","JNE","C","T","T","SSO","SSE","C","C","T","T","C","H"]
L8=["T","T","C","JSO","JSE","C","T","T","C","C","C","C","SG","SD","C","H"]
L9=["T","SY","Y","C","C","C","T","T","C","PNO","PNE","C","MNO","MNE","C","H"]
L10=["C","C","C","C","C","C","T","T","C","PSO","PSE","C","MSO","MSE","C","H"]
L11=["H","H","H","H","H","H","T","T","C","C","C","C","C","C","C","H"]
L12=["H","E","E","E","E","H","T","T","T","T","T","T","C","E","C","H"]
L13=["H","E","E","E","PO","H","T","T","T","T","SG","SD","C","PO","C","H"]
L14=["H","H","H","H","H","H","C","C","C","C","HNO","HNE","C","E","C","H",]
L15=["C","C","C","C","C","C","C","C","C","C","HSO","HSE","C","C","C","H",]
L0P=["M","FH","M","FH","FH","M","FH","M"]
L1P=["M","FB","M","FB","FB","M","FB","M","M"]
L2P=["LH","LH","PA","PA","PA","PA","CNO","CNE",]
L3P=["LB","LB","PA","PA","PA","PA","CSO","CSE",]
L4P=["PA","PA","PA","PA","PA","PA","PA","PA",]
L5P=["PA","TNO","TNE","PA","PA","PA","PA","PA",]
L6P=["PA","TSO","TSE","PA","PA","PA","PA","PA",]
L7P=["PA","PA","PA","PA","PA","PAP","PA","PA",]
japon=[L0,L1,L2,L3,L4,L5,L6,L7,L8,L9,L10,L11,L12,L13,L14,L15]
maison_interior=[L0P,L1P,L2P,L3P,L4P,L5P,L6P,L7P]
#creation de la map
dico={"SG":casesoljG,"SY":casesoljY,"SD":casesoljD,"SH":casesoljH,"SB":casesoljB,"B":casebleu,"H":caseherbe,"C":casecerisier,"ANO":caseaeroNO,"ANE":caseaeroNE,"ASO":caseaeroSO,"ASE":caseaeroSE,"HNO":casemaisonhkNO,"HNE":casemaisonhkNE,"HSO":casemaisonhkSO,
"SNO":casesushiNO,"SNE":casesushiNE,"SSO":casesushiSO,"SSE":casesushiSE,"PNO":casepagodeNO,"PNE":casepagodeNE,"PSO":casepagodeSO,"PSE":casepagodeSE,
"MNO":casemaisonNO,"MNE":casemaisonNE,"MSO":casemaisonSO,"MSE":casemaisonSE,"HSE":casemaisonhkSE,"T":casesolj,"E":caseeau,"PO":caseeaupoisson,
"JNO":casepagodejNO,"JNE":casepagodejNE,"JSO":casepagodejSO,"JSE":casepagodejSE,"Y":caseyoshi,"PA":caseparquet,"PAP":caseparquetp,"M":casemur,"FH":casefenetreh,"FB":casefenetreb,
"CNO":casechatNO,"CNE":casechatNE,"CSO":casechatSO,"CSE":casechatSE,"LH":caselith,"LB":caselitb,"TNO":casetableNO,"TNE":casetableNE,"TSO":casetableSO,"TSE":casetableSE}
for i in range(16):
    for j in range(16):
        can1.create_image(50*j,50*i,image=dico[japon[i][j]],anchor="nw")

#position du personnage
posX=100  
posY=0
 
perso=can1.create_image(posX,posY,image=persoD1,anchor="nw")
#zones de texte
texte_pnj=can1.create_text(350,850,text="",font=("Arial",13),fill="black")




def Clavier(event):
    #event recupère l'information tapee sur le clavier
    global posX,posY
    touche=event.keysym
    colonne=posX//50
    ligne=posY//50
    if touche=='Up' and japon[ligne-1][colonne]!="C" :
        mvt_haut()
    if touche=='Down' and japon[ligne+1][colonne]!="C" :
        mvt_bas()
    if touche=="Right" and japon[ligne][colonne+1]!="C" and japon[ligne][colonne+1]!="PNO" and japon[ligne][colonne+1]!="PSO":
        mvt_droite()
    if touche=="Left" and japon[ligne][colonne-1]!="C" and japon[ligne][colonne-1]!="H" :
        mvt_gauche()

def mvt_gauche():
    """deplace à gauche le perso"""
    global perso,posX,posY,compteur_de_pas,texte_pnj
    posX=posX-50
    if posX<0 :
        posX=00
    #mise à  jour de l'image
    can1.itemconfig(perso,image=tab_gauche[compteur_de_pas%2])
    compteur_de_pas+=1
    #mise à  jour des coordonnées
    can1.coords(perso,posX,posY)
    if posX==50  and posY==0 :
        can1.after(100,aeroport)

def mvt_haut():
    """deplace le perso vers le haut"""
    global perso,posY,posX,compteur_de_pas
    posY=posY-50
    if posY<0 :
        posY=0
    #mise à  jour de l'image
    can1.itemconfig(perso,image=tab_gauche[compteur_de_pas%2])
    compteur_de_pas+=1
    #mise à jours
    can1.coords(perso,posX,posY)

def mvt_bas():
    """deplace le perso vers le haut"""
    global perso,posY,posX,compteur_de_pas
    posY=posY+50
    if posY<0 :
        posY=0
    #mise à  jour de l'image
    can1.itemconfig(perso,image=tab_gauche[compteur_de_pas%2])
    compteur_de_pas+=1
    #mise à  jour des coordonnées
    can1.coords(perso,posX,posY)
    if posX==400  and posY==350 :
        can1.itemconfig(texte_pnj,text="test")
    if posX==450  and posY==300 :
        can1.itemconfig(texte_pnj,text="test")
    if posX==500  and posY==700 :
        can1.itemconfig(texte_pnj,text="test")
    if posX==550 and posY==700 :
        can1.itemconfig(texte_pnj,text="test")
    if posX==600  and posY==450 :
        can1.after(100,maison)
    if posX==650  and posY==450 :
        can1.after(100,maison)


def mvt_droite():
    """deplace a droite le perso"""
    global perso,posX,posY,compteur_de_pas
    posX=posX+50
    if posX>800 :
        posX=800
    #mise à jour de l'image
    can1.itemconfig(perso,image=tab_droite[compteur_de_pas%2])
    compteur_de_pas+=1
    #mise  jour des coordonnee s
    can1.coords(perso,posX,posY)
    if posX==100 and posY==450 :
        can1.itemconfig(texte_pnj,text="test")
    if posX==400  and posY==350 :
        can1.itemconfig(texte_pnj,text="test")
    if posX==400  and posY==300 :
        can1.itemconfig(texte_pnj,text="test")

def maison():
    global perso,posX,posY,compteur_de_pas
    Mafenetre.geometry('400x400')
    can1.destroy()
    for i in range(8):
        for j in range(8):
            can2.create_image(50*j,50*i,image=dico[maison_interior[i][j]],anchor="nw")
        posX=250  #abscisse de depart
        posY=350
    #ordonné part
        perso2=can2.create_image(posX,posY,image=persoD1,anchor="nw")

def aeroport():
    Mafenetre2=Tk()
    Mafenetre2.geometry('400x400')
    button1= Button(Mafenetre2, text ="FRANCE")
    button1.place(x=170, y=100, )
    button2=Button(Mafenetre2, text ="JAPON",command = Mafenetre2.destroy)
    button2.place(x=170, y=200)
    button3= Button(Mafenetre2, text ="AMERIQUE")
    button3.place(x=170, y=300)
    Mafenetre2.mainloop()
#programme principal


can1.focus_set()
can1.bind('<Key>',Clavier)


Mafenetre.mainloop()
0