pendu.py

Created by chambounaudaubin

Created on April 03, 2025

2.87 KB


from time import *
from ion import *
from kandinsky import *
from random import *
touche={18:"a",19:"b",20:"c",21:"d",22:"e",23:"f",24:"g",25:"h",26:"i",27:"j",28:"k",29:"l",30:"m",31:"n",32:"o",33:"p",34:"q",36:"r",37:"s",38:"t",39:"u",40:"v",42:"w",43:"x",44:"y",45:"z"}
liste=["maison","voiture","cheval","table","velo","chaise","stylo","chien","chat","lit","tapis","livre","cube","boite","jeux","video","lampe","python","coussin","laideur","france","cahier","lutin","trou","lacet","lait","eau","aide","luxe","humain","chose","pendu","course","girafe","cerf","casque","trottinette","alpes","paris","ile","la","le","lapin","anticonstitutionellement","lynx","singe","atome","lien","foret","roche","lichen","pantalon","tyrannosaure","volcan","weekend","avion","zebre","chapeau","elephant","echelle","evaluation","calculatrice","tableau","culotte","affiche","symetrie","concert","cinema","xylophone","tambour","karate","sport","athletisme","yoga","zen","echecs","monopoly","mythe","mythologie","couture","xenophobie","whisky","musculature","agenda","teeshirt","automobile","crayon","cheveux","affiche"]
couleur,non,reponse,indice,reste,position=color(0,40,60),"",liste[randint(0,len(liste)-1)],"",[],[]
fill_rect(0,0,320,222,couleur)
for i in range(0,len(reponse)):indice=indice+"-"
tout=len(reponse)+6
for tour in range(1,len(reponse)+7):
  draw_string(str(tour)+"/"+str(tout),270,205,"white",couleur)
  draw_string(indice,int((320-len(indice)*10)/2),120,"white",couleur)
  indice_l=[]
  for i in range(0,len(reponse)):indice_l.append(indice[i])
  draw_string("Donne une lettre: ",60,80,"white",couleur)
  draw_string("PENDU par Aubin",70,10,"white",couleur)
  lettre=""
  while len(lettre)==0:
    for i in range(18,46):
      if keydown(i):lettre=touche[i]
  if lettre in reponse:
    for i in range(0,len(reponse)):
      if reponse[i]==lettre:position.append(i)
    for element in range(0,len(position)):
      for i in range(position[element],len(indice_l)):reste.append(indice_l[i])
      qas=len(indice_l)
      for i in range(position[element],qas):indice_l.pop(len(indice_l)-1)
      if len(reste)>0:reste.pop(0)
      indice_l.append(lettre)
      for i in range(0,len(reste)):indice_l.append(reste[i])
      reste=[]
    indice=""
    fill_rect(0,0,320,222,couleur)
    for i in range(0,len(indice_l)):indice=indice+indice_l[i]
    indice_l=[]
    position=[]
    detect_l=[]
  elif not lettre in non:non=non+" "+str(lettre)
  draw_string(str(non),int((320-len(non)*10)/2),150,"white",couleur)
  sleep(0.3)
  if indice==reponse:
    draw_string("Bravo! C'etait       ",80,150,"white",couleur)
    draw_string(indice,int((320-len(indice)*10)/2),170,"white",couleur)
    break
if indice!=reponse:
  fill_rect(0,0,320,222,couleur)
  draw_string("Perdu! C'etait         ",80,150,"white",couleur)
  draw_string(reponse,int((320-len(indice)*10)/2),170,"white",couleur)
draw_string("PENDU par Aubin",70,10,"white",couleur)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.