Visualiser des lignes de champs de forces (gravité, etc…) sur un objet.
Utiliser Ok pour opposer la gravité de l’objet
from kandinsky import * from ion import * from time import * px,py=0,0 sens=1 #===/\ #set it to 1 or -1 #and test 0, -2, 3, 2.5... space=32 #===/\ #set also it to 20 or 40 to test color=(128+(127*sens),0,128-(127*sens)) try: draw_line(0,0,0,0,(0,0,0)) except: def draw_line(x1,y1,x2,y2,c): width=x2-x1 height=y2-y1 if abs(width)>=abs(height): div=height/width for i in range(0,width,(width>0)*2-1): set_pixel(x1+i,y1+int(div*i),c) else: div=width/height for i in range(0,height,(height>0)*2-1): set_pixel(x1+int(div*i),y1+i,c) def dist(x,y): return ((x-px)**2+(y-py)**2)**0.5 def draw_all(): for x in range(space//2,330,space): for y in range(space//2,230,space): d=int(dist(x,y)) try: i_d=sens/d**2*1000 except: i_d=0 fill_rect(x-1,y-1,3,3,(180,)*3) if i_d: draw_line(x,y,x+int((px-x)*i_d),y+int((py-y)*i_d),(180,)*3) fill_rect(px-3,py-3,7,7,color) while True: for i in range(4): if keydown(i): fill_rect(0,0,320,222,(255,)*3) px+=[-1,0,0,1][i]*5 py+=[0,-1,1,0][i]*5 px%=320 py%=220 if keydown(KEY_OK): fill_rect(0,0,320,222,(255,)*3) sens*=-1 color=(128+(127*sens),0,128-(127*sens)) draw_all() sleep(0.05)