Sound Button by Brux29th Aug 2014 15:15
|
---|
Summary Example how to make a button with sound Description Example how to make a button with sound Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com Rem ************************** Rem * * Rem * Button with Sound * Rem * By Ermanno (Italy) * Rem * * Rem * e-mail: me52@libero.it * Rem ************************** Rem define some colors red=RGB(255,0,0) white=RGB(255,255,255) gray=RGB(83,83,83) green=RGB(137,176,19) blu=RGB(12,158,184) Load Sound "select.wav",1 Load Sound "press.wav",2 Sync On Sync Rate 30 Make_Button(white,10,10,630,470,white,white,1) Make_Button(gray,250,200,450,260,white,black,1) Make_Button(green,270,220,430,240,white,black,2) Intesto(270,210,430,220,"Click Me",blu) Do If Mousex()>270 And Mousex()<430 And Mousey()>220 And Mousey()<240 Make_Button(green,270,220,430,240,black,white,1) Intesto(270,210,430,220,"Exit ?",red) If flag=0 Play Sound 1 flag=1 EndIf Else Make_Button(green,270,220,430,240,white,black,1) Intesto(270,210,430,220,"Click Me",white) flag=0 EndIf If Mouseclick()>0 If Mousex()>270 And Mousex()<430 And Mousey()>220 And Mousey()<240 Make_Button(blu,270,220,430,240,black,white,2) Intesto(270,210,430,220,"BYE BYE",white) Sync Play Sound 2 Wait 1000 End EndIf EndIf Sync Loop Function Make_Button(co1,Left,Top,Right,Bottom,co2,co3,shadow) Ink 0,0 If shadow=1 Then Box left,top,right,bottom If shadow=2 Then Box left-2,top-2,right+2,bottom+2 Ink co1,co1 Box left+1,top+1,right-1,bottom-1 Ink co2,co2 Line Left,Bottom,Left,Top : Line Left,Top,Right,Top Ink co3,co3 Line Right,Top,Right,Bottom : Line Right,Bottom,Left,Bottom EndFunction Function Intesto(x,y,x1,y1,txt$,ct) Ink ct,ct c=((x1-x)/2)-((8*Len(txt$))/2) Text x+c,y1-((y1-y)/2)+8,txt$ EndFunction |