Voici comment créer des niveaux pour le jeu chute.py !
from random import * from kandinsky import * from ion import * from time import * back_color=(0,)*3 def draw_instruction(): fill_rect(0,0,320,222,back_color) for i in range(len(instruction)): draw_string(instruction[i],5,10+i*30,(200,)*3,back_color) instruction=[ "OK pour changer d'objet", "les fleches pour bouger l'objet", "copy pour doubler l'objet", "<x pour supprimer l'objet", ")+fleche pour changer la taille", "EXE pour avoir le code source", "OK pour passer a la suite →", ] type=[ [], [120,120,20,30,5], [30,30,20,10] ] edit=[ [[40, 130], [240, 130]], [[120, 100, 20, 30, 5]], [[40, 130, 220, 10]] ] edit_id=0 type_id=0 def draw_all(): fill_rect(0,0,320,222,back_color) for i in edit[2]: fill_rect(i[0],i[1],i[2],i[3],(0,0,200)) for i in edit[1]: fill_rect(i[0]+3,i[1],17,30,(0,255,0)) fill_rect(i[0],i[1]+3,12,10,(200,)*3) fill_rect(edit[0][0][0],edit[0][0][1]-5,20,5,(255,150,100)) fill_rect(edit[0][1][0],edit[0][1][1]-5,20,5,(100,100,255)) draw_instruction() sleep(1) while not keydown(KEY_OK): sleep(0.05) while True: try: draw_all() sleep(0.1) if keydown(KEY_OK): edit_id+=1 if keydown(KEY_VAR): if not type_id==0: edit[type_id]+=[[None,[randint(1,7)*10,randint(1,7)*10,20,30,5],[randint(1,7)*10,randint(1,7)*10,20,10]][type_id],] if keydown(KEY_BACKSPACE) and type_id in (1,2) and len(edit[type_id])>1: del edit[type_id][edit_id] if len(edit[type_id])<=edit_id: edit_id=0 type_id=(type_id+1)%3 for i in range(4): if keydown(i): edit[type_id][edit_id][[0,1,1,0][i]]+=[-1,-1,1,1][i]*10 if keydown(KEY_RIGHTPARENTHESIS) and type_id==2: edit[type_id][edit_id][[0,1,1,0][i]]-=[-1,-1,1,1][i]*10 edit[type_id][edit_id][[2,3,3,2][i]]+=[-1,-1,1,1][i]*10 if keydown(KEY_EXE): print(edit) break except: print(edit) break