joeeee2017
Nombre de messages : 60 Date d'inscription : 13/10/2017
| Sujet: calculatrice avec touches movibles Dim 15 Oct 2017 - 0:11 | |
| je suis pas doué avec le forum je remets mon post car je vois pas celui que je viens de poster ou je disais ,j ai essayé de faire une calculatrice ou on deplace les touches pour recuperer leurs positions dans un fichier mais j ai du mal a les deplacer - Code:
-
dim a$,aa$,op,i,a,b,b$,c$,u,n,l,h,d,v dim t(40,2),tx$(20),coul,c1,c2,c3,xpad,ypad,yy,xx,zx,zy,click
label calcul,fin,men,men1,men2,carre,virgule,euro,col label sauve,dep2,col2
main_menu 20 sub_menu 21:caption 21,"Quitte":parent 21,20 sub_menu 22:caption 22,"sauve ":parent 22,20 sub_menu 23:caption 23,"deplacer touche ":parent 23,20 on_click 22,sauve:on_click 21,fin
left 0,1000:top 0,1 width 0,337:height 0,572 caption 0,"Calculatrice" color 0,236,233,216
data 127,330,202,330,277,330,127,255,202,255,277,255,127,180,202,180,277,180 data 127,405,202,405,352,255,352,180,277,405,352,330,352,405,127,480,127,144,345,144 data "1","2","3","4","5","6","7","8","9","0",".","*","/","C","-","+","=","euro","franc"
l=114:h=59:c1=204:c2=153:c3=0 for i=1 to 19 button i:read a:read b left i,a-l:top i,b-h:width i,65:height i,65 t(i,1)=a-l:t(i,2)=b-h next i
width 17,290:height 17,70 width 18,070:height 18,26 width 19,070:height 19,26
for i=1 to 19 read c$:tx$(i)=c$ font_size i,25:caption i,c$ next i
edit 40 left 40,127-l:top 40,77-h width 40,287:height 40,70 font_size 40,26:font_size 18,14:font_size 19,14
2d_pen_width 7 gosub col 2d_pen_color 252,152,0 2d_rectangle 125-l,75-h,418-l,135-h
on_click 0,col on_click 18,euro on_click 19,euro rem ------------------------------------------- men: op=2:b$="":a$="":text 40,"0":d=0 rem -------------------------------------------- men1: aa$=inkey$ u=0 men2: for i=1 to 17 if clicked(i)=1 then u=i:gosub carre next i rem --- if clicked(23)=1 then d=d+1 if d>1 then d=0:a$=text$(40):goto men2 if d=1 and u>0 then gosub dep2:goto men2 rem ---------------------------------- if u=0 then goto men1 if u=14 then goto men if u=10 then u=0 if u=11 then gosub virgule:goto men1 if u=17 then gosub calcul:op=2:b$="":goto men1 if u>11 then op=u:gosub calcul:b$="":goto men1 rem ----------------- if op=2 then a$="" if b$="" then text 40,"" b$=b$+str$(u):text 40,b$ goto men1 rem --------------------------------------------- calcul: if a$="" then a$=b$:b$="" if b$="" then return if op=13 and val(b$)=0 then beep:text 40,a$:return if op=12 then a$=str$(val(a$)*val(b$)) if op=13 then a$=str$(val(a$)/val(b$)) if op=15 then a$=str$(val(a$)-val(b$)) if op=16 then a$=str$(val(a$)+val(b$)) text 40,a$:b$="" return rem ---------------------------------- dep2: aa$=inkey$ xpad=mouse_x_position(0) ypad=mouse_y_position(0) if mouse_left_up(0)=1 then click=0 if mouse_left_down(0)=1 then click=1 if click=0 then return 2d_pen_color c1,c2,c3 2d_rectangle xpad-15,ypad-15,xpad+80,ypad+80 t(u,1)=xpad:t(u,2)=ypad left u,xpad:top u,ypad goto dep2 return rem ---------------------- sauve: file_open_write 25,"donée calc.txt" for i=1 to 19 file_writeln 25, t(i,1) file_writeln 25, t(i,2) file_writeln 25, tx$(i) next i file_close 25:message "un fichier nommé donée calc.txt vient d' etre créé " return rem --------------------------------------------- carre: if u=0 or u=17 then return 2d_pen_color 247,79,0 2d_rectangle t(u,1)-2,t(u,2)-2,t(u,1)+67,t(u,2)+67 wait 80 2d_pen_color c1,c2,c3 2d_rectangle t(u,1)-2,t(u,2)-2,t(u,1)+67,t(u,2)+67 return rem --------------------------------------------- virgule: v=0:n=len(b$) for i=1 to n if mid$(b$,i,1)="." then v=1 next i if n=0 then b$=b$+"0.":text 40,b$:return if v=0 then b$=b$+".":text 40,b$:return if v=1 then beep return rem --------------------------------------------- euro: if clicked(18)=1 then text 40,str$(val(text$(40))/6.55957) if clicked(19)=1 then text 40,str$(val(text$(40))*6.55957) return rem --------------------------------------------- col: if d=1 then goto col2 c1=c1+12.75:if c1>254 then c1=0 c2=c2+25.5:if c2>254 then c2=0 c3=c3+51:if c3=>254 then c3=0 col2: 2d_fill_color c1,c2,c3:2d_pen_color 0,0,0:2d_rectangle 1,1,428-l,557-h return rem --------------------------------------------- fin: terminate return
| |
|