Here's what I have so far ... it needs some adjustments ... I'm doing something more elegant ....in the meanwhile take a look .
// Project: flying Sliders
// Created: 2019-05-12
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "flying Sliders" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
w=makecolor(100,140,100)
drawbox(0,0,20,20,w,w,w,w,1)
render()
getimage(1,0,0,20,20)
wb=makecolor(70,70,70)
drawbox(0,0,20,20,wb,wb,wb,wb,1)
render()
getimage(2,0,0,20,20)
`Main sprite
createsprite(1,1)
setspritesize(1,100,150)
`header
clonesprite(100,1)
setspritesize(100,100,30)
setspritecolor(100,130,130,255,255)
setspriteposition(100,40,40)
`Slider
createsprite(4,2)
setspritesize(4,90,6)
setspritecolor(4,10,10,10,255)
`slider boton
createsprite(2,2)
setspritesize(2,15,20)
`Mouse
createsprite(3,2)
setspritesize(3,15,15)
setspritevisible(3,0)
gosub _update
sl=0
createobjectbox(1,1000,1000,1)
setobjectcolor(1,100,100,255,0)
do
x#=getpointerx()
y#=getpointery()
sx#=getspritex(3) `mouse spritex
sy#=getspritey(3) `mouse spritey
setspriteposition(3,x#,y#) `mouse
if GetRawMouseleftstate()
if getspritecollision(3,100)
setspriteposition(100,x#+(getspritex(100)-sx#),y#+(getspritey(100)-sy#))
gosub _update
endif
endif
for i= 1 to 100
if getspritecollision(3,2) and GetRawMouseleftState()>0
if abs(getspritex(2)-getpointerx())<20
if sl<80 and getspritex(2)< x# then inc sl
if sl>0 and getspritex(2)>x# then dec sl
setspriteposition(2,sl+getspritex(1),getspritey(1)+5)
endif
endif
next
set_cursor(10)
print(sl)
set_cursor(5)
print("Use LEFT mouse boton to place")
Sync()
loop
function set_cursor(p)
for i= 1 to p
print("")
next
endfunction
_update:
setspriteposition(1,getspritex(100),getspritey(100)+30)
setspriteposition(4,getspritex(1)+5,getspritey(1)+10)
setspriteposition(2,sl+getspritex(1)+5,getspritey(1)+5)
return
Little update.
// Project: flying Sliders
// Created: 2019-05-12
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "flying Sliders" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
w=makecolor(100,140,100)
drawbox(0,0,20,20,w,w,w,w,1)
render()
getimage(1,0,0,20,20)
wb=makecolor(70,70,70)
drawbox(0,0,20,20,wb,wb,wb,wb,1)
render()
getimage(2,0,0,20,20)
`Main sprite
createsprite(1,1)
setspritesize(1,100,150)
`header
clonesprite(100,1)
setspritesize(100,100,30)
setspritecolor(100,130,130,255,255)
setspriteposition(100,140,140)
`Slider
createsprite(4,2)
setspritesize(4,90,6)
setspritecolor(4,10,10,10,255)
`slider boton
createsprite(2,2)
setspritesize(2,15,20)
`Mouse
createsprite(3,2)
setspritesize(3,15,15)
setspritevisible(3,0)
sl=7
`Sky
createobjectbox(1,1000,1000,1)
setobjectcolor(1,100,100,255,0)
`header title
createtext(1,"Example")
Settextsize(1,25)
SetTextColor(1,255,255,0,255)
`empty text
createtext(2,"")
Settextsize(2,20)
SetTextColor(2,255,255,0,255)
`rounded box
createsprite(50,0)
setspritesize(50,80,60)
setspritecolor(50,100,255,100,255)
clonesprite(51,50)
setspritesize(51,82,58)
do
gosub _update
x#=getpointerx()
y#=getpointery()
sx#=getspritex(3) `mouse spritex
sy#=getspritey(3) `mouse spritey
setspriteposition(3,x#,y#) `mouse
if GetRawMouseleftstate()
if getspritecollision(3,100)
setspriteposition(100,x#+(getspritex(100)-sx#),y#+(getspritey(100)-sy#))
gosub _update
endif
endif
for i= 1 to 100
if getspritecollision(3,2) and GetRawMouseleftState()>0
if abs(getspritex(2)-getpointerx())<20
if sl<77 and getspritex(2)< x# then inc sl
if sl>7 and getspritex(2)>x# then dec sl
setspriteposition(2,sl+getspritex(1),getspritey(1)+5)
endif
endif
next
set_cursor(0)
print("Use RMB to place "+" " +valor$)
valor$=str(sl-7)
SetTextString(2,""+valor$)
Sync()
loop
function set_cursor(p)
for i= 1 to p
print("")
next
endfunction
_update:
setspriteposition(1,getspritex(100),getspritey(100)+30)
setspriteposition(4,getspritex(1)+5,getspritey(1)+10)
setspriteposition(2,sl+getspritex(1),getspritey(1)+5)
settextposition(1,getspritex(100)+12,getspritey(100))
settextposition(2,getspritex(100)+12,getspritey(100)+70)
setspriteposition(50,getspritex(100)+10,getspritey(100)+100)
setspritecolor(50,100+sl,190+sl,120+sl,255)
setspriteposition(51,getspritex(100)+9,getspritey(100)+101)
setspritecolor(51,100+sl,190+sl,120+sl,255)
return
I'm not a grumpy grandpa
