oui_non_chat.py

Created by leno-m

Created on May 01, 2023

1.74 KB

Un chat à l’interface cool qui répond uniquement par oui ou par non. Amusez vous à lui poser des question drôles sur votre avenir on dit qu’il ne dis que la vérité.


from math import *

from kandinsky import *
from ion import *
import time
from random import *


adolf="^^^^^^^^^^^^^^^^^abcdefghijklmnopq^rstuv^wxyz ^?!^^^^^^^^^^^^^^^^^^^^[]{}_→ghi=<>789()^456*/^123+-^0.^^^"
chat=["","","","","","","","","","",""]
requet=""
lettres=[]
x=55
y=5
index=52

def touche():
  global x
  global index
  global requet
  if keydown(KEY_BACKSPACE) and len(lettres)>0:
      x-=10
      draw_string("  ",x,202,"gray","black")
      lettres.pop()
      draw_string(" ",x,202,"green","white")
  
  if keydown(KEY_ALPHA):
    if index==0:
      index=52
    else:
      index=0
        
  for KEY in range(KEY_UP,KEY_EXE+1):
    if keydown(KEY) and not adolf[KEY+index-1]=="^":
      lettres.append(adolf[KEY+index-1])
      if adolf[KEY-1]==" ":
        draw_string(" ",x,202,"white","black")
      else:
        draw_string(adolf[KEY-1+index],x,202,"white","black")
      x+=10
      draw_string(" ",x,202,"green","white")
      
def drawchat():
  global y
  fill_rect(0,0,320,222,"black")
  for i in range(11):
    if chat[i]==">>> oui":
      draw_string(chat[i],5,y,"green","black")
    if chat[i]==">>> non":
      draw_string(chat[i],5,y,"red","black")
    if not chat[i]==">>> oui" and not chat[i]==">>> non":
      draw_string(chat[i],5,y,"white","black")
    y+=17
  draw_string("/>...",5,202,"white","black")
  
while True:
  drawchat()
  time.sleep(0.15)
  while not keydown(KEY_EXE):
    touche()
    time.sleep(0.07)
  for i in range(len(lettres)):
    requet+=lettres[i]
    
  chat.remove(chat[0])
  chat.append(requet)
  x=55
  y=5
  drawchat()
  requet=""
  lettres=[]
  time.sleep(randint(1,2))
  if randint(0,1)==0:
    chat.append(">>> non")
  else:
    chat.append(">>> oui")
  chat.remove(chat[0])
  x=55
  y=5 
  

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.