black_or_white.py

Created by frablock

Created on June 21, 2022

815 Bytes

Un petit jeu, utilisez les flèches du clavier pour vous déplacer, et [ok] pour valider


from kandinsky import *;from time import *;from ion import *;from random import *
fr,ds,kd=fill_rect,draw_string,keydown
def pu(a,c="1",x=10,y=75,w=300,h=75):fr(x,y,w,h,(0,0,0));fr(x+1,y+1,w-2,h-2,c);ds(a,x+2,y+2,"0",c);ds("[ok]",x+2,y+h-20,"0",c)

def p(n,c):
 global m
 m,t=n,50
 fr(81+162*m-t//2,112-t//2,t,t,"red")
 fr(86+162*m-t//2,117-t//2,t-10,t-10,str(c))
 fr(81+162*(1-m)-t//2,112-t//2,t,t,str(1-d[m]))
def dr():
 global a,d
 a=randint(0,1)
 b=1-a
 d=[a,b]
 fr(0,0,325//2,225,str(a))
 fr(325//2,0,325//2,225,str(b))
g,s,m=0,0,0
while not kd(5) and not g:
 dr()
 ds(str(s),0,0)
 c=str(randint(0,1))
 p(m,c)
 while not kd(5):
  if kd(KEY_LEFT):p(0,c)
  if kd(KEY_RIGHT):p(1,c)
  if kd(KEY_OK):
   if str(d[m])==c:s+=1;break
   else:pu("GAME OVER\nScore : "+str(s));g=1;break
 sleep(0.2)

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.