osu.py

Created by kbdechez-lidl

Created on January 27, 2023

1.73 KB


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

def clear():
  h=0
  for i in range(25):
    draw_string("                                      ",0,h)
    h=h+15

def menu():
  max=50
  nbmenu=1
  draw_string("[OK] pour commecer",70,50)
  while True:
    draw_string(str(max),200,100)
    if keydown(KEY_OK)==True:
      print(clear())
      print(jeu(max))
      sleep(0.1)
    if keydown(KEY_PLUS)==True:
      draw_string("   ",200,100)
      sleep(0.1)
      nbmenu=nbmenu-1
    if keydown(KEY_PLUS)==True:
      draw_string("   ",200,100)
      sleep(0.1)
      nbmenu=nbmenu+1
    if nbmenu==0:
      max=20
    if nbmenu==1:
      max=50
    if nbmenu==2:
      max=70
    if nbmenu==3:
      max=100
    if nbmenu<0:
      nbmenu=3
    if nbmenu>3:
      nbmenu=0
      
    
def jeu(max):
  compte=0
  while True:
    draw_string(str(compte)+"/"+str(max),140,0)
    r=randint(1,4)
    if r==1:
      draw_string("HAUT",140,80)
      while True:
        if keydown(KEY_UP)==True:
          compte=compte+1
          draw_string("    ",140,80)
          break
    elif r==2:
      draw_string("DROITE",170,100)
      while True:
        if keydown(KEY_RIGHT)==True:
          compte=compte+1
          draw_string("      ",170,100)
          break
    elif r==3:
      draw_string("BAS",140,120)
      while True:
        if keydown(KEY_DOWN)==True:
          compte=compte+1
          draw_string("   ",140,120)
          break
    elif r==4:
      draw_string("GAUCHE",100,100)
      while True:
        if keydown(KEY_LEFT)==True:
          compte=compte+1
          draw_string("      ",100,100)
          break
    if compte==max+1:
      print(menu())        
            
    
print(menu())