hi guys ^^ do you have advice for me? Code: #classes/fonctions# from random import* from tkinter.messagebox import * class personnage: def __init__(self, vie=20, nom="Sans nom"): self.vie=vie self.nom=nom def afficheEtat (self): texte.insert (END,"il reste "+str(self.vie)+" points de vie à "+self.nom+"\n") def subitAttaque (self,attaquant): texte.insert (END,attaquant+' attaque '+self.nom+'\n') tauxReussite=random() if tauxReussite<0.8: texte.insert (END,"L'attaque de "+ attaquant+" a réussi, \n"+self.nom+ " est blessé \n") force=randint(-4,1) self.vie=self.vie-10+force else: texte.insert (END,"L'attaque de "+attaquant+" a échoué \n") hero=personnage(100,'Hero') def combat(): ennemi=personnage(50,"ennemi") while (hero.vie>0) & (ennemi.vie>0): texte.insert(END,"Que faites vous ?\n") if hero.vie !=0 : hero.subitAttaque("ennemi") hero.afficheEtat() if ennemi.vie !=0 : ennemi.subitAttaque("hero") ennemi.afficheEtat() if ennemi.vie<=0 : texte.insert (END,"Vous avez vaincu l'ennemi !\n") elif hero.vie<=0 : texte.insert(END,"Vous etes mort !\n") else: texte.insert(END,"Que faites vous ?\n") def action(): if askyesno('Titre 1', 'Voulez-vous fuir ?'): showwarning('Titre 2', 'Vous prenez la fuite !') Fp.delete(photo1) else: showinfo('Titre 3', 'Bon courage !') #fenetre# from tkinter import * Fp = Tk() Fp.geometry('1150x900') Barrey = Scrollbar(Fp) Barrey.grid(row=1, column=2) def info(): combat() texte=Text(Fp, width=40, height=45, yscrollcommand=Barrey.set) texte.grid(row=1, column=1) texte.insert(END,"Un voleur vous attaque ! \n") Button(Fp, text="Combattre", command=info).grid(row=2, column= 3) Button(Fp, text="Quitter", command=Fp.destroy).grid(row= 2,column=4) Button(Fp, text="Action", command=action).grid(row=2, column= 1) photo=PhotoImage(file="/home/lubuntu/forest.gif") photo1=PhotoImage(file="/home/lubuntu/voleur2.gif") zone_dessin =Canvas(Fp,width=750,height=750,bg="brown",bd=8,relief="ridge") zone_dessin.create_image(180,180,image=photo) zone_dessin.create_image(400,400,image=photo1) zone_dessin.grid(row=1, column=3) Canvas.grid(row=1,column=3,rowspan=3) Barrey.config(command=texte.yview) Fp.mainloop()
+ its hard to understand the names, it would help using english names for methods, variables and also what is your expectation?
If it really matters, you can use code tags to maintain spacing. I don't think this is long enough for that to matter, but... Anyway, I haven't used python in 5~6 years. Don't even remember the basics! *poses proudly*
well spoiler dosn't allow the space T-T but i want it to work and to know if you think that something could have been done in a better way
hrm i dont get the main part since i cant code but from what i understand about coding is that you have to define everyhting and i dont know about hero and enemy definition?
I really hoped you wouldn't say that. You. From Canada, where I currently live. It is a cruel world we live in.
texte.insert(END,"Un voleur vous attaque ! \n") Button(Fp, text="Combattre", command=info).grid(row=2, column= 3) Button(Fp, text="Quitter", command=Fp.destroy).grid(row= 2,column=4) Button(Fp, text="Action", command=action).grid(row=2, column= 1) anyone can guess when there are french sentence....