Jeu du "qui est ce" a réaliser
Benchouxx
-
Zephirr Messages postés 389 Statut Membre -
Zephirr Messages postés 389 Statut Membre -
Bonjour,
Nous avons besoins d'aide pour faire notre jeu du "Qui est ce" sous Python.
Nous avons realiser déjà ces queqlue lignes de code, mais nous ne savons pas par ou commencer ensuite. Nous voulons que l'ordinateur choisisse au hazard parmis 24 personnges ( qui seront des photos de personnes). Ensuite nous devons deviner le personnage en cliquant sur des questions placer dans un cadre ou un menu deroulant. L'ordinateur repond par oui ou non et supprime les images des personnes éliminés.
Nous voudrions juste avoir un peu d'aide pour comprendre les etapes a faires, par ou commancé et ce qui ne va pas dans notre programme.
merci.
EDIT: Ajout de la coloration syntaxique.
Nous avons besoins d'aide pour faire notre jeu du "Qui est ce" sous Python.
Nous avons realiser déjà ces queqlue lignes de code, mais nous ne savons pas par ou commencer ensuite. Nous voulons que l'ordinateur choisisse au hazard parmis 24 personnges ( qui seront des photos de personnes). Ensuite nous devons deviner le personnage en cliquant sur des questions placer dans un cadre ou un menu deroulant. L'ordinateur repond par oui ou non et supprime les images des personnes éliminés.
Nous voudrions juste avoir un peu d'aide pour comprendre les etapes a faires, par ou commancé et ce qui ne va pas dans notre programme.
merci.
from tkinter import*
from random import*
#les variable
#sex
s1='fille'
s2='garcon'
#Peau
p1='blanche'
p2='noire'
#Yeux
y1='marron'
y2='vert'
y3='bleu'
#cheveux
g1='long'
g2='court'
c1='noir'
c2='chatain'
c3='blond'
#lunette
l1='oui'
l2='non'
#Chapeau
h1='oui'
h2='non'
#Personnage
#fille
personne1=[s1,p2,y1,g1,c1,l2,h1,"A"]
personne2=[s1,p1,y2,g2,c3,l1,h2,'B']
personne3=[s1,p2,y2,g2,c2,l2,h2,'C']
personne4=[s1,p1,y3,g1,c1,l1,h1,"D"]
personne5=[s1,p2,y2,g1,c1,l1,h2,'E']
personne6=[s1,p1,y3,g2,c3,l2,h2,"F"]
personne7=[s1,p2,y1,g2,c1,l1,h2,'G']
personne8=[s1,p1,y3,g2,c3,l2,h1,'H']
personne9=[s1,p2,y2,g1,c2,l2,h1,'I']
personne10=[s1,p1,y2,g1,c1,l1,h2,'J']
personne11=[s1,p2,y1,g1,c2,l1,h1,'K']
personne12=[s1,p1,y2,g2,c1,l1,h2,'L']
#garcon
personne13=[s2,p1,y1,g2,c3,l2,h2,'M']
personne14=[s2,p1,y1,g1,c2,l1,h1,'N']
personne15=[s2,p1,y2,g2,c2,l2,h1,'O']
personne16=[s2,p1,y2,g1,c1,l2,h2,'P']
personne17=[s2,p1,y3,g2,c3,l2,h2,'Q']
personne18=[s2,p1,y3,g2,c3,l1,h2,'R']
personne19=[s2,p2,y1,g2,c1,l2,h2,'S']
personne20=[s2,p2,y1,g1,c2,l2,h2,'T']
personne21=[s2,p2,y1,g1,c1,l1,h2,'U']
personne22=[s2,p2,y1,g2,c3,l2,h2,'V']
personne23=[s2,p2,y2,g2,c2,l2,h2,'W']
personne24=[s2,p2,y2,g2,c1,l2,h1,'X']
#Le personnage choisit
x=[personne1,personne2,personne3,personne4,personne5,personne6,personne7,personne8,personne9,personne10,personne11,personne12,personne13,personne14,personne15,personne16,personne17,personne18,personne19,personne20,personne21,personne22,personne23,personne24]
#Les Definitions :
def change():
fenetre.geometry("800x500")
boutonstart.place_forget()
texte.place_forget()
def fille():
if x.sex==s1:
reponse.configure(text="oui")
elif x.sex==s2:
reponse.configure(text="non")
def garcon():
if x.sex==s1:
reponse.configure(text="non")
elif x.sex==s2:
reponse.configure(text="oui")
def blanche():
if x.peau==p1:
reponse.configure(text="oui")
elif x.peau==p2:
reponse.configure(text="non")
def noire():
if x.peau==p1:
reponse.configure(text="non")
elif x.peau==p2:
reponse.configure(text="oui")
def marron():
if x.yeux==y1:
reponse.configure(text="oui")
elif x.yeux==y2 or x.yeux==y3:
reponse.configure(text="non")
def vert():
if x.yeux==y2:
reponse.configure(text="oui")
elif x.yeux==y1 or x.yeux==y3:
reponse.configure(text="non")
def bleu():
if x.yeux==y3:
reponse.configure(text="oui")
elif x.yeux==y1 or x.yeux==y2:
reponse.configure(text="non")
def noir():
if x.cheveux==c1:
reponse.configure(text="oui")
elif x.cheveux==c2 or x.yeux==c3:
reponse.configure(text="non")
def chatain():
if x.cheveux==c2:
reponse.configure(text="oui")
elif x.cheveux==c1 or x.yeux==c3:
reponse.configure(text="non")
def blond():
if x.cheveux==c3:
reponse.configure(text="oui")
elif x.cheveux==c1 or x.yeux==c2:
reponse.configure(text="non")
def long():
if x.grandeur==g1:
reponse.configure(text="oui")
elif x.grandeur==g2:
reponse.configure(text="non")
def court():
if x.grandeur==g2:
reponse.configure(text="oui")
elif x.grandeur==g1:
reponse.configure(text="non")
def lunette():
if x.lun==l1:
reponse.configure(text="oui")
elif x.lun==l2:
reponse.configure(text="non")
def chapeau():
if x.chap==h1:
reponse.configure(text="oui")
elif x.chap==h2:
reponse.configure(text="non")
fenetre=Tk()
fenetre.title('Jeu : Qui est ce ? ')
fenetre.geometry("800x500")
boutonstart=Button (fenetre,text="Jouer", width=20,bg='red', fg='white', command=change)
boutonstart.place(x=300, y=250)
texte=Label(fenetre, text="Le Jeu du 'Qui es ce ?'",fg='red')
texte.config(font=('times',30,'bold'))
texte.place(x=150, y=50)
choix=randrange(0,23)
print('cest',x[0][7])
fenetre.mainloop()
EDIT: Ajout de la coloration syntaxique.
A voir également:
- Jeu du "qui est ce" a réaliser
- 94 jeu - Télécharger - Puzzle & Réflexion
- 94 degrés jeu - Télécharger - Divers Jeux
- Jeu du pendu - Télécharger - Vie quotidienne
- Jeu zuma - Télécharger - Jeux vidéo
- Jeu google - Guide
1 réponse
Je n'avais jamais utilisé tkinter avant, mais je vous propose tout de même ce code:
j'ai préféré utiliser la POO, car elle me semblait plus appropriée ici.
Mon utilisation de tkinter me semble approximative, donc tout correction est bienvenue ;)
import random
from tkinter import*
from tkinter import ttk
sexe_list = ["fille","garcon"]
peau_list = ["blanche","noire"]
yeux_list = ["marron","vert","bleu"]
class Personne:
def __init__(self, sexe, peau, yeux):
if sexe in sexe_list:
self.sexe = sexe
if peau in peau_list:
self.peau = peau
if yeux in yeux_list:
self.yeux = yeux
personnes_list = []
for s in sexe_list:
for p in peau_list:
for y in yeux_list:
personnes_list.append(Personne(s,p,y))
x = personnes_list[random.randint(0,11)];
def change():
fenetre.geometry("800x500")
boutonstart.place_forget()
texte.place_forget()
categorieSelect = StringVar()
categories = ('sexe', 'yeux', 'peau')
listeCategories = ttk.Combobox(textvariable = categorieSelect, \
values = categories, state = 'readonly')
listeCategories.place(x=10, y=10)
bouttonValider = Button(fenetre,text="Valider", width=10,bg='blue', fg='white', command=lambda: v1(categorieSelect), height = 1)
bouttonValider.place(x=10,y=40)
def v1(c):
if c.get() != "":
categorieSelect = StringVar()
categories = ("a")
if c.get() == "sexe":
categories = sexe_list
if c.get() == "peau":
categories = peau_list
if c.get() == "yeux":
categories = yeux_list
listeCategories = ttk.Combobox(textvariable = categorieSelect, \
values = categories, state = 'readonly')
listeCategories.place(x=10, y=70)
bouttonValider = Button(fenetre,text="Valider", width=10,bg='blue', fg='white', command=lambda: v2(categorieSelect), height = 1)
bouttonValider.place(x=10,y=100)
def v2(c):
text = ""
if c in sexe_list and c == x.sexe:
text = "Oui"
elif c in yeux_list and c == x.yeux:
text = "Oui"
elif c in peau_list and c == x.peau:
text = "Oui"
else:
text = "Non"
texte = Text(fenetre, width = 4,height = 1)
texte.insert(END, text)
texte.place(x=10,y=130)
texte.config(state=DISABLED)
fenetre=Tk()
fenetre.title('Jeu : Qui est ce ? ')
fenetre.geometry("800x500")
boutonstart=Button (fenetre,text="Jouer", width=20,bg='red', fg='white', command=change)
boutonstart.place(x=300, y=250)
texte=Label(fenetre, text="Le Jeu du 'Qui es ce ?'",fg='red')
texte.config(font=('times',30,'bold'))
texte.place(x=150, y=50)
fenetre.mainloop()
j'ai préféré utiliser la POO, car elle me semblait plus appropriée ici.
Mon utilisation de tkinter me semble approximative, donc tout correction est bienvenue ;)